Is there some option to bundle react core and my scripts separately? for example two files:
bundle-ract.js
( include react, react-dom, redux, immutable) bundle.js
( my application and scripts ) Of course, there's such way. You have to define multiple entries in your webpack config. Similarly to this:
const path = require('path');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
module.exports = {
entry: {
'SubItems': './src/modules/sub-items/sub.items.module.js',
'UniversalDiscovery': './src/modules/universal-discovery/universal.discovery.module.js',
'MultiFileUpload': './src/modules/multi-file-upload/multi.file.upload.module.js',
},
output: {
filename: '[name].module.js',
path: path.resolve(__dirname, 'Resources/public/js'),
library: ['eZ', 'modules', '[name]'],
libraryTarget: 'umd',
libraryExport: 'default',
},
devtool: 'source-map',
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}
]
},
externals: {
'react': {
root: 'React',
commonjs2: 'react',
commonjs: 'react',
amd: 'react'
},
'react-dom': {
root: 'ReactDOM',
commonjs2: 'react-dom',
commonjs: 'react-dom',
amd: 'react-dom'
}
},
plugins: [
new CleanWebpackPlugin(['Resources']),
new UglifyJSPlugin({
sourceMap: true,
uglifyOptions: {
ecma: 6
}
})
]
};
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.