我安装了sass-loader,css-loader和style-loader。这是我的webpack配置:
var HTMLWebpackPlugin = require('html-webpack-plugin');
var HTMLWebpackPluginConfig = new HTMLWebpackPlugin({
template: __dirname + '/app/index.html',
filename: 'index.html',
inject: 'body'
});
module.exports = {
entry: __dirname + '/app/index.js',
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /\.scss$/,
loaders: ['style-loader', 'css-loader']
}
]
},
output: {
filename: 'index.js',
path: __dirname + '/build'
},
plugins : [HTMLWebpackPluginConfig]
};
我在同一个文件夹中有2个scss文件:main.scss和variable.scss。我想将你的导入变量.scss导入main.scss但失败并显示错误消息:"找不到模块:错误:无法解析'变量' &#34 ;.这是我的main.scss:
@import "variables";
body {
color: black;
}
答案 0 :(得分:0)
您可能需要安装并添加sass-loader的配置,这也需要node-sass作为依赖:https://github.com/webpack-contrib/sass-loader