I bundled project with webpack 1. Project is consist of several folders. I noticed that js file that did not imported anywhere also end up in the bundle. Why does it happened?
As i know Webpack should resolve dependency graph and bundle file regarding it.But it seems it just bundle all files from the project directory.
Here is a part of my config:
entry: {
app: [path.resolve(__dirname, '../src/main.js')]
},
output: {
path: path.resolve(__dirname, '../dist'),
filename: '[name].[hash].js',
publicPath: '/',
chunkFilename: '[id].chunk.js'
},
resolve: {
extensions: ['', '.js', '.jsx'],
},
Remove the empty string from resolve extension.
I prefer to use the loaders module like so:
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['react', 'es2015', 'stage-0', 'es2015-ie'],
plugins: ['react-html-attrs', 'transform-class-properties', 'transform-decorators-legacy'],
}
},
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.