我遇到错误
“无效的配置对象。已使用与API架构不匹配的配置对象初始化Webpack。 -配置具有未知属性“模式”。这些属性有效: 对象{amd,bail,cache,context,dependencies,devServer,devtool,entry,externals,loader,module,name,node,output,parallelism,performance,plugins ?,配置文件,recordsInputPath,recordsOutputPath,recordsPath,resolve,resolveLoader,stats,target,watch,watchOptions? } 对于错别字:请更正它们。 对于加载程序选项:webpack 2不再允许配置中的自定义属性。 应该更新加载程序,以允许通过module.rules中的加载程序选项传递选项。 在加载程序更新之前,可以使用LoaderOptionsPlugin将这些选项传递给加载程序: 插件:[ 新的webpack.LoaderOptionsPlugin({ //测试:/。xxx $ /,//仅可将其应用于某些模块 选项:{ 模式:... } }) ] “
似乎有点不舒服,因为构建突然停止了工作。我想我正在将项目从一个地方移到另一个地方,在运行npm run build为项目准备生产之前,我遇到了这个问题。我到处都看了很多问题,但是找不到答案,在一些帮助下会很棒。
我尝试安装babel-core,babel-preset-env和uninstallet babel和vue-cli,但没有成功。还值得一提的是,我将main.css文件和一些javascript代码从src映射之外移到了src映射中。不确定是不是导致问题的原因。
这是我的webpack.config.js文件
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: './src/main.js',
output: {
path: path.resolve(__dirname, './dist'),
publicPath: '/dist/',
filename: 'build.js'
},
module: {
rules: [
{
test: /\.css$/,
use: [
'vue-style-loader',
'css-loader'
],
}, {
test: /\.vue$/,
loader: 'vue-loader',
options: {
loaders: {
}
// other vue-loader options go here
}
},
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/
},
{
test: /\.(png|jpg|gif|svg)$/,
loader: 'file-loader',
options: {
name: '[name].[ext]?[hash]'
}
}
]
},
resolve: {
alias: {
'vue$': 'vue/dist/vue.esm.js'
},
extensions: ['*', '.js', '.vue', '.json']
},
devServer: {
historyApiFallback: true,
noInfo: true,
overlay: true
},
performance: {
hints: false
},
devtool: '#eval-source-map'
}
if (process.env.NODE_ENV === 'production') {
module.exports.devtool = '#source-map'
// http://vue-loader.vuejs.org/en/workflow/production.html
module.exports.plugins = (module.exports.plugins || []).concat([
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: '"production"'
}
}),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: false
}
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
])
}
这是我的package.json文件
{
"name": "the-ultimate-website",
"description": "A Vue.js project",
"version": "1.0.0",
"author": "Marvin <marvinkristusbenno@gmail.com>",
"license": "MIT",
"private": true,
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"@babel/polyfill": "^7.2.5",
"babel": "^6.23.0",
"babel-core": "^6.26.3",
"babel-loader": "^8.0.5",
"babel-preset-env": "^1.7.0",
"babel-preset-stage-3": "^6.24.1",
"bootstrap-vue": "^2.0.0-rc.14",
"joi": "^14.3.1",
"jshint-loader": "^0.8.4",
"vee-validate": "^2.2.0",
"vue": "^2.5.11",
"vue-resource": "^1.5.1",
"vue-router": "^3.0.2"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
],
"devDependencies": {
"cross-env": "^5.0.5",
"css-loader": "^2.1.1",
"file-loader": "^1.1.4",
"vue-loader": "^13.0.5",
"vue-template-compiler": "^2.4.4",
"webpack": "^3.6.0",
"webpack-cli": "^3.3.0",
"webpack-dev-server": "^3.2.1"
}
}