Module build failed (from ./node_modules/css-loader/dist/cjs.js):
    CssSyntaxError

    (1:4) Unknown word

    > 1 | // style-loader: Adds some css to the DOM by adding a <style> tag
        |    ^
      2 | 
      3 | // load the styles

     @ ./node_modules/vue-slider-component/theme/antd.css 4:14-338 14:3-18:5 15:22-346

在Webpack 4中构建应用程序时出现此错误.这是我的CSS加载程序配置:

{
    test: /\.css$/,
    use: ["vue-style-loader", "css-loader", "postcss-loader"]
},
{
    test: /\.scss$/,
    use: ["vue-style-loader", "css-loader", "postcss-loader", "sass-loader"]
}

我怎样才能稍微放松一下规则,这样就不会在这些问题上失败?

谢谢

推荐答案

你不能有多个css加载器.以下是一个可能的解决方案:

      {
        test: /\.(sa|sc|c)ss$/,
        use: [
          'vue-style-loader',
          'css-loader',
          'sass-loader',
          'postcss-loader',
        ]
      }

Vue.js相关问答推荐

带 Bootstrap 的 Vue js,导航栏菜单不起作用

如何在Vue3中使用vuechartjs 5.2从父组件更新图表

当try 更新 Vue 3 中的关联数组中的单个元素时,所有值都会更新

Vuejs - 更新数组中对象的数组

nuxt.js - 预加载 .woff 字体加载为@font-face

根据 URL 有条件地隐藏视图组件

Vue @click 不适用于存在 href 的anchor锚标记

更新 vue.js 中的数据属性/对象

vue-router的router-link实际刷新?

在组件外使用 VueI18n 的问题

VueJS 使用 prop 作为数据属性值

Vue.js:TypeError:无法设置只有 getter 的 # 的属性props

取消选中单选按钮

在手动安装的 vue 组件中使用 vuex

如何异步验证 Vuetify 文本字段?

如何从 vue 组件调用 App.vue 中的方法

了解 Nuxt.js 中的State状态和Getters:Getters不起作用

使用 Vue.js & DataTable(jquery 插件)

使用 Firebase Auth for Google 将匿名用户转换为注册用户

如何从 keep-alive 中销毁缓存的 Vue 组件?