【问题标题】:Can't include scss file in the css nuxt.config.js configuration无法在 css nuxt.config.js 配置中包含 scss 文件
【发布时间】:2019-01-13 13:52:45
【问题描述】:

我试图在 css nuxt.config.js 选项中包含一个 scss 文件,但是当我运行时

npm run dev

我收到以下错误:

This dependency was not found:

* ..\assets\css\main.scss in ./.nuxt/App.js

To install it, you can run: npm install --save ..\assets\css\main.scss

这是我的 package.json :

  "dependencies": {
    "bootstrap-vue": "^2.0.0-rc.11",
    "nuxt": "^1.0.0"
  },
  "devDependencies": {
    "babel-eslint": "^8.2.1",
    "eslint": "^4.15.0",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-vue": "^4.0.0",
    "node-sass": "^4.9.2",
    "sass-loader": "^7.1.0"
  }

还有css配置:

css: [
    "@/assets/css/main.scss",
  ],

main.scss 文件位于 assets/css/main.scss 下:

@import "node_modules/bootstrap/scss/bootstrap";

* {
  font-family: "Quicksand";
  margin: 0;
  padding: 0;
}

.full-width {
  width: 100%;
}

【问题讨论】:

  • 你能发布你的整个配置文件吗?可能是您缺少花括号或其他东西。

标签: nuxt.js


【解决方案1】:

正如docs 指出的那样,验证您是否安装了sass-loadersassfibers(npm 包)。

npm install --save-dev sass sass-loader fibers

验证url路径,检查指定url中是否存在文件

css: [
    '@/assets/scss/main.scss'
]

你可以使用style-resources-module

参考here

【讨论】:

  • 这个解决方案对我不起作用,我仍然得到错误
猜你喜欢
  • 2017-08-10
  • 1970-01-01
  • 2016-12-07
  • 1970-01-01
  • 2020-01-13
  • 2022-11-19
  • 2018-10-20
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多