NuxtJS & SASS Loader - Build with sass-loader (SCSS) on production

陌路散爱 提交于 2019-12-22 12:41:44

问题


I've added this lines to build with sass-loader on development (local) server:

nuxt.config.js

module.exports = {

  mode: 'spa',

  build: {
    analyze: {
      analyzerMode: 'static',
      generateStatsFile: true,
      statsFilename: 'webpack-stats.json',
      openAnalyzer: false
    },
    vendor: [
      'axios',
      'vuetify'
    ],
    extend (config) {
      config.resolve.alias['vue'] = 'vue/dist/vue.common'
      const vueLoader = config.module.rules.find((rule) => rule.loader === 'vue-loader')
      vueLoader.options.loaders.scss = 'vue-style-loader!css-loader!sass-loader?' + JSON.stringify({
        includePaths: [
          path.resolve(__dirname), 'node_modules'
        ]
      })
    }
  }

  ...
}

The problem is on production, I've this error:

Cannot find module "!!vue-style-loader!css-loader!../../../node_modules/vue-loader/lib/style-compiler/index?{"vue":true,"id":"data-v-7ef06ffa","scoped":true,"hasInlineConfig":true}!sass-loader?{"includePaths":["/app/config","node_modules"]}!../../../node_modules/vue-loader/lib/selector?type=styles&index=0!./index.vue"

This question is available on Nuxt.js community (#c6871)

回答1:


Ok, I haven't need of this config on nuxt.config.js, just install sass-loader and node-sass in "dependencies", not in "devDependencies".



来源:https://stackoverflow.com/questions/49735461/nuxtjs-sass-loader-build-with-sass-loader-scss-on-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!