vuejs/vue-cli

ModuleNotFoundError when using sass @import in combination with css modules

Open

#2,334 创建于 2018年8月23日

在 GitHub 查看
 (3 评论) (7 反应) (0 负责人)JavaScript (29,754 star) (6,328 fork)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

贡献者指南