Ale*_*Kim 10 webpack vue.js css-loader
生产构建失败并出现以下错误:
ValidationError: Invalid options object. CSS Loader has been initialised using an options object that does not match the API schema.
- options has an unknown property 'minimize'. These properties are valid:
object { url?, import?, modules?, sourceMap?, importLoaders?, localsConvention?, onlyLocals? }
at validate (/Users/username/Sites/projectname/node_modules/css-loader/node_modules/schema-utils/dist/validate.js:85:11)
at Object.loader (/Users/username/Sites/projectname/node_modules/css-loader/dist/index.js:34:28)
Run Code Online (Sandbox Code Playgroud)
使用这个 webpack 模板:http ://vuejs-templates.github.io/webpack/ ,更新到 Webpack 4 并面临构建问题,package.json:
{
"name": "projectname",
"private": true,
"scripts": {
"dev": "webpack-dev-server --inline --progress --config webpack.config.js --port 3000 --hot",
"start": "npm run dev",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
"dependencies": {
"@vue/cli-service": "^3.2.0",
"axios": "^0.18.0",
"babel-polyfill": "^6.26.0",
"cross-env": "^5.2.0",
"css-loader": "^3.2.1",
"jquery": "^3.3.1",
"moment": "^2.22.2",
"style-loader": "^1.0.1",
"swiper": "^4.5.0",
"v-tabs-router": "^1.4.0",
"vee-validate": "^2.1.0-beta.9",
"vue": "^2.5.2",
"vue-awesome-swiper": "^3.1.3",
"vue-backtotop": "^1.6.1",
"vue-carousel": "^0.18.0",
"vue-cleave-component": "^2.1.2",
"vue-instant": "^1.0.2",
"vue-jsonp": "^0.1.8",
"vue-magic-line": "^0.2.1",
"vue-masked-input": "^0.5.2",
"vue-resource": "^1.5.1",
"vue-router": "^3.0.2",
"vue-select": "^2.5.1",
"vue-slider-component": "^2.8.0",
"vue-smooth-scroll": "^1.0.13",
"vuejs-datepicker": "^1.5.3",
"vuelidate": "^0.7.4",
"vuex": "^3.0.1"
},
"devDependencies": {
"autoprefixer": "^7.1.2",
"babel-core": "^6.22.1",
"babel-helper-vue-jsx-merge-props": "^2.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-syntax-jsx": "^6.18.0",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-plugin-transform-vue-jsx": "^3.5.0",
"babel-preset-env": "^1.3.2",
"babel-preset-stage-2": "^6.22.0",
"chalk": "^2.0.1",
"copy-webpack-plugin": "^4.0.1",
"extract-text-webpack-plugin": "^3.0.0",
"file-loader": "^5.0.2",
"friendly-errors-webpack-plugin": "^1.6.1",
"html-webpack-plugin": "^3.2.0",
"node-notifier": "^5.1.2",
"node-sass": "^4.13.0",
"optimize-css-assets-webpack-plugin": "^5.0.3",
"ora": "^1.2.0",
"portfinder": "^1.0.13",
"postcss-import": "^12.0.1",
"postcss-loader": "^3.0.0",
"postcss-url": "^8.0.0",
"rimraf": "^2.6.0",
"sass-loader": "^8.0.0",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"uglifyjs-webpack-plugin": "^1.1.1",
"url-loader": "^1.1.2",
"vue-loader": "^14.2.2",
"vue-resource": "^1.5.1",
"vue-style-loader": "^4.1.2",
"vue-template-compiler": "^2.5.2",
"webpack": "^4.41.2",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.9.0"
},
"engines": {
"node": ">= 6.0.0",
"npm": ">= 3.0.0"
},
"browserslist": [
"> 1%",
"last 2 versions",
"not ie <= 8"
]
}
Run Code Online (Sandbox Code Playgroud)
我已经检查grep -rl 'minimize' .了项目根目录,但没有找到任何相关选项。与..
Kax*_*axa 13
我喜欢 webpack 中 postcss 的这个问题。原因是旧版本使用语法:
{
loader: 'postcss-loader',
options: {
plugins: postCSSPlugins
}
}
Run Code Online (Sandbox Code Playgroud)
虽然选项中的新版本在插件之前使用嵌套的 postcssOptions:
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: postCSSPlugins
}
}
}
Run Code Online (Sandbox Code Playgroud)
我在更新到 webpack 4 并使用 MiniCssExtractPlugin 时也遇到了这个错误
我能够通过使用旧版本的 ccs-loader 消除错误并成功构建
这些版本对我有用
"devDependencies": {
"css-loader": "1.0.1",
Run Code Online (Sandbox Code Playgroud)
或者
"css-loader": "^0.28.0",
Run Code Online (Sandbox Code Playgroud)
css-loader 2* 和 3* 给了我错误。
测试发布后更新:使用旧版本的 css-loader 会导致在浏览器中渲染网站时 css 无法加载。所以这似乎不是一个解决方案。
我运行yarn upgrade --latest命令后遇到了同样的问题。
它将 sass-loader 版本从 7.1.0 更改为 8.0.0。之后得到同样的错误。
sass-loader 选项可能发生变化,因此发生此错误。您可以检查版本:https://github.com/webpack-contrib/sass-loader/releases和更新的选项https://github.com/webpack-contrib/sass-loader
尝试删除/更改 sass-loader 选项,这可以帮助您解决问题。
希望这能有所帮助,如果您能分享 webpack.config.js 文件,那就太好了。
干杯~
| 归档时间: |
|
| 查看次数: |
17173 次 |
| 最近记录: |