vuejs/vue-cli

ModuleNotFoundError when using sass @import in combination with css modules

Open

#2,334 opened on 2018年8月23日

GitHub で見る
 (3 comments) (7 reactions) (0 assignees)JavaScript (29,754 stars) (6,328 forks)batch import
bugcontribution welcomehelp wantedscope: cli-service build

説明

Version

3.0.0-rc.11 - 3.0.5

Reproduction link

https://github.com/dattn/vue-cli-bug-demo

Node and OS info

Node v10.9.0 / Ubuntu 18.04

Steps to reproduce

npm install
npm run build

What is expected?

The scss files should be imported with Sass. The code should build successfully.

What is actually happening?

The relative scss files cannot be found. The build fails with the following error message:

Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js):
ModuleNotFoundError: Module not found: Error: Can't resolve './variables'

With vue-cli v3.0.0-rc.10, the code builds as expected. The problem exists as of version 3.0.0-rc.11. The latest version 3.0.5 also fails.

I think the source of the problem is the following commit: https://github.com/vuejs/vue-cli/commit/4220835

When I add the following props to the vue.config.js, the build works again:

module.exports = {
  css: {
    loaderOptions: {
      css: { importLoaders: 3 }
    }
  }
}

Related issue: #2055

コントリビューターガイド