【发布时间】:2021-02-26 20:06:51
【问题描述】:
我正在学习使用 Webpack 构建我的 react 项目。 我已经配置了一个 webpack.config.js 来加载 CSS 文件。
webpack.config.js:
module.exports = {
...
module: {
rules: [
{
test: /\.css$/,
exclude: /(node_modules)/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
],
},
{
test: /\.scss$/,
exclude: /(node_modules)/,
use: [
{ loader: 'style-loader' },
{ loader: 'css-loader' },
{ loader: 'sass-loader' },
],
},
...
],
},
...
}
npm 运行构建
出现了这个问题。
Module parse failed: Unexpected token (6:3) You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders | * Copyright 2011-2020 Twitter, Inc. | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) > */:root{--blue:#007bff;--indigo:#6610f2;--purple:#6f42c1;--pink:#e83e8c;--red:#dc3545; ..... ```
我不明白该怎么做。谢谢。
【问题讨论】: