无法在css nuxt.config.js配置中包含scss文件

时间:2018-08-06 14:53:52

标签: nuxt.js

我试图在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文件位于asset / css / main.scss下:

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

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

.full-width {
  width: 100%;
}

1 个答案:

答案 0 :(得分:0)

确认已安装sass-loader和node-sass(npm软件包)

npm i -D node-sass sass-loader

验证网址路径,并检查文件是否存在于指定的网址中

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

您可以使用style-resources-module

推荐here