Vladimir37
Vladimir37

Reputation: 568

Webpack not worked

I have project with such structure:

Project
    node_modules
        ...
    com
        adding.js
        App.js
        Footer.js
        Todo.js
        TodoList.js
    action.js
    reducers.js
    store.js
    build.js

And I have this build file:

var path = require('path');
var webpack = require('webpack');
var config = {
    context: __dirname,
    entry: ['redux', 'react', 'react-redux', './action', './reducers', './store', './com/adding', './com/Todo', './com/TodoList', './com/Footer', './com/App'],
    output: {
        path: path.join(__dirname, 'assets')
    },
    module: {
        loaders: [
            { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"}
        ]
    }
};
var compiler = webpack(config);
compiler.run(function (err, stats) {
    if(err) {
        console.log('Error:' + err);
    }
    else {
        console.log('Win');
    }
});

But when I compiled and start bundle.js I get this error: Error: Cannot find module "./store". What's wrong? Files reducers.js and action.js work normal, but store.js and all files in folder com not find.

Upvotes: 0

Views: 68

Answers (1)

spacek33z
spacek33z

Reputation: 2253

The entry parameter in config is wrong. Usually you specify one (or some) entry point here. In that file you can use import to import all dependencies you've now listed in the entry array.

I think this starter repository can help you a lot setting up webpack, React and Reflux.

Upvotes: 1

Related Questions