在对项目文件进行打包时可能会出现如下错误提示:
Invalid configuration object.Webpack has been initialised using a configuration object that does not match the API schema.
- configuration.resolve.extensions[1] should not be empty.
-> A non-empty string
这句话fa翻译过来就是:配置对象是无效的。webpack在初始化过程中,使用的配置对象与API模式中的不匹配。
在配置项目中resolve对象的extension[1] 的不应该为空。应该是一个非空字符串。
配置文件可能如下:
module.exports = {
entry: {
index: './main'
},
output: {
path: path.join(__dirname, 'dist/js'),
filename: '[name].js',
libraryTarget: 'umd',
library: 'avalon'
},
plugins: [
new webpack.BannerPlugin('This is Model' + api)
],
module: {
rules: [
{test: /\.scss$/, loader:'style-loader!css-loader!sass-loader',exclude: /node_modules/},
{test: /\.(ttf|eot|svg|woff2?)((\?|#)[^\'\"]+)?$/, loader: 'url-loader'}
]
},
resolve: {
extensions: ['.js', '', '.css'] //问题就出在这里
}
}
提示已经说得很清楚了,resolve里的extensions[1] 不能为空.
而这也是webpack4的语法规范之一,wp4要求数组元素不能为空,若为空的话要用 * 来取代
所以可以修改为
resolve: {
extensions: ['.js', '*', '.css'] //现在就没问题了
}