我在设置webpack时遇到此问题webpack.validateSchema is not a function
并在下面做出反应我共享了webpack.config.js
const path = require('path');
const merge = require('webpack-merge');
const webpack = require('webpack');
const TARGET = process.env.npm_lifecycle_event;
const PATHS = {
app: path.join(__dirname, 'app'),
build: path.join(__dirname, 'build')
};
const common = {
entry: {
app: PATHS.app
},
output: {
path: PATHS.build,
filename: 'bundle.js'
},
module: {
loaders: [
{
test: /\.css$/,
loaders: ['style','css'],
include: PATHS.app,
}
]
}
};
if(TARGET === 'start' || !TARGET){
module.exports = merge(common, {
devtool: 'eval-source-map',
devServer: {
contentBase: PATHS.build,
historyApiFallback: true,
hot: true,
inline: true,
progress: true,
stats: 'errors-only',
host: process.env.HOST,
port: process.env.PORT || 3000
},
plugins: [
new webpack.HotModuleReplacementPlugin()
]
});
}
if(TARGET === 'build'){
module.exports = merge(common, {});
}
答案 0 :(得分:1)
要解决几个错误:
extension: ['','.js','.jsx']
而不是extensions: ['.js','.jsx']
。自webpack 2以来就没有必要使用空条目,它会抱怨它。['style','css']
而不是['style-loader','css-loader']
。从webpack 2开始,默认情况下它不提供快捷方式。babel?cacheDirectory
而不是babel-loader?cacheDirectory
。我可以通过use
和options
重写定义,如同the webpack book chapter。