麻烦大家帮我解决。。我的webpack.config.js是在项目根目录有一个,在特定的功能文件夹一个,打包时候,在根目录运行webpack命令,js文件里面引入X文件夹的另一个webpack.config.js,这样我可以通过切换文件夹路径决定打包哪个模块。
!!!!下面是X文件夹里面的config
const webpack = require('webpack');
const filePath = './BehaviorHabit/src/main/webapp/resources/wx/js/assessPage_demo';
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
// devtool: 'cheap-module-eval-source-map',
entry: {
'./BehaviorHabit/src/main/webapp/resources/wx/js/common/commonPlugins': ["jquery", "jquery.mmenu", "react", "react-dom"],
'./BehaviorHabit/src/main/webapp/resources/wx/js/assessPage_demo/dist/bundle': filePath + '/js/assessEntry.js'
},
output: {
filename: '[name].js'
},
module: {
loaders:[
{
test: /\.js|js[x]?$/,
exclude: /node_modules/,
query: {presets: ['es2015','react']} ,
loader:"babel"
// loader: 'babel-loader?presets[]=es2015&presets[]=react',
},
// {
// test: /\.css$/,
// // modules&localIdentName=[local] 加上modules表示使用css模块化 、
// // localIdentName是对css命名,[name]模块(文件)名 [local]类名 [hash:base64:5] hash值
// loader: 'style!css?modules&localIdentName=[local]'
// // &localIdentName=[name]localIdentName=[name]__[local]___[hash:base64:5]
// // loader: 'style-loader!css-loader'
// },
{
test: /\.css$/,
loader: ExtractTextPlugin.extract("style-loader", "css-loader")
},
// {
// test: /\.(png|jpg)$/,
// loader: 'url-loader?limit=8192'
// },
{ test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/, loader: 'url-loader?limit=50000&name=[path][name].[ext]'}
]
},
plugins: [
new webpack.optimize.CommonsChunkPlugin({
name: ['./BehaviorHabit/src/main/webapp/resources/wx/js/common/commonPlugins', './BehaviorHabit/src/main/webapp/resources/wx/js/common/manifest'],
minChunks : Infinity
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
}),
new webpack.ProvidePlugin({
"React": "react",
"ReactDOM": "react-dom",
$ : "jquery",
}),
new ExtractTextPlugin("./style.css"),
],
};
!!!这里是根目录的config cfg就是上面的X文件夹的config.js 就是上面那段代码
const webpack = require('webpack')
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var cfg = require('./BehaviorHabit/src/main/webapp/resources/wx/js/assessPage_demo/webpack.config.js');
module.exports = {
// devtool: 'cheap-module-eval-source-map',
entry: cfg.entry,
output: cfg.output,
module: cfg.module,
plugins: cfg.plugins
};
运行webpack后报错是Chunk.entry was removed. Use hasRuntime() ,请问这是什么原因?找了很久找不到答案。。请问大神这个报错应该怎么解决T T
ps: style-loader css-loader extract-text-webpack-plugin这些都已经install了。。。