question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

VUE CLI with webpack 4 does not support chainWebpack properly

See original GitHub issue

Version

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:closed
  • Created 5 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
andriytyurnikovcommented, May 18, 2018

@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:

//vue.config.js
const path = require('path')

module.exports = {
  css: {
    loaderOptions: {
      sass: {
        includePaths: [path.resolve(__dirname, 'node_modules')]
      }
    }
  }
}
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found