VUE CLI with webpack 4 does not support chainWebpack properly
See original GitHub issueVersion
3.0.0-beta.10
Reproduction link
https://github.com/LanFeusT23/vue-cli-webpack-issue
Steps to reproduce
vue create project Add a vue.config.js file and tap into some loader options
// vue.config.js
module.exports = {
chainWebpack: config => {
config.module
.rule('scss')
.use('sass-loader')
.tap(options =>
merge(options, {
includePaths: [path.resolve(__dirname, 'node_modules')],
})
)
}
}
npm run serve
It will throw an error when trying to tap into the loader options
What is expected?
The options should be a an object with many more properties.
What is actually happening?
the options object only has the following properties: { compilerOpitons: { preserveWhitespace: false } }
options.loaders.scss throws an exception because options doesn’t have any other properties added.
This worked fine until webpack 4 was released.
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Working with Webpack
The easiest way to tweak the webpack config is providing an object ... based on values in vue.config.js and should not be mutated...
Read more >ISO proper way to chain Webpack via vue.config.js to add ...
My problem is I'm setting up a NativeScript/Vue.js project with vue-cli-plugin-nativescript-vue and was curious if anyone has successfully ...
Read more >Configuration | Vue CLI Plugin Electron Builder - GitHub Pages
These functions work similarly to the chainWebpack (opens new window) option provided by Vue CLI. Note: Do NOT change the webpack output directory...
Read more >How to Migrate from Vue CLI to Vite
Learn how to migrate from Vue CLI to Vite in 9 simple steps for a ... sorry but <%= htmlWebpackPlugin.options.title %> doesn't work...
Read more >single-spa-vue
Install systemjs-webpack-interop if you have not already done so. ... Note that if you are using the Vue CLI Plugin, your main.ts or...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
https://github.com/vuejs/vue-cli/blob/dev/docs/config.md
@yyx990803 , thanks a lot for your answer. While exploring various cli starter kits, I’ve encountered multiple challenges with the use of sass libraries. I wonder if there any reason why loading SASS and LESS dependencies from node_modules is not a default behavior?
As my primary scenario with those is to stand on shoulders of giants (sass libraries and frameworks), it looks like people optimize starter kits for other scenarios.
Is such default evil in some way?
BTW, for those who seek copy-paste solution: