我正在尝试让 webpack 编译和提供 scss 文件。不幸的是,无论我做什么和更改 *.scss 文件都不会被解析。webpack 所做的唯一一件事就是生成一个 bundle.js 文件,该文件服务于所有 js 内容。我不太确定这个配置有什么问题。
let path = require("path");
let webpack = require('webpack');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractCSS = new ExtractTextPlugin("styles.css");
module.exports = {
devtool: 'inline-source-map',
entry: [
'./src/index.js',
],
resolve: {
modules: [
"src",
'node_modules'
],
extensions: ['.js', '.jsx', '.scss']
},
output: {
path: path.resolve(__dirname, "build"),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
'react-hot-loader',
'babel-loader?presets[]=react,presets[]=es2015',
]
},
{
test: /\.scss$/,
include: path.join(__dirname, 'app', 'scss'),
use: extractCSS.extract({
fallback: 'style-loader',
use: [
'css-loader',
'sass-loader?outputStyle=expanded'
]
})
}
]
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
extractCSS
],
};
使用以下源树:
ROOT
/build
/src
/scss
index.js
webpack.config.js
packages.json