是否有办法将react和我的脚本分别捆绑在一起?例如,有两个文件:
bundle-ract.js (包括反应、反应、还原、不变)bundle.js (我的应用程序和脚本)发布于 2018-05-11 06:17:27
当然,有这样的方法。您必须在webpack配置中定义多个条目。与此类似:
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
}
})
]
};https://stackoverflow.com/questions/50286071
复制相似问题