虽然 css 文件解析得很好,但在 scss 中它根本无法解析。有谁知道解决方案?Sass-loader 告诉我使用“resolve-url-loader”,但我无法让它工作。我试图添加字体真棒。如果我使用css版本它工作得很好(文件加载器甚至将字体复制到dist)但没有scss。
这是我的产品配置文件。
webpack.production.js
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserJSPlugin = require('terser-webpack-plugin');
const plugins = [
new HtmlWebpackPlugin({
inject: false,
hash: true,
template: __dirname + '/../src/app/Views/layouts/layout-template.phtml',
filename: __dirname + '/../src/app/Views/layouts/layout.phtml'
}),
new MiniCssExtractPlugin({
filename: 'css/[name].css',
chunkFilename: 'css/[name].css',
}),
];
module.exports = () => ({
output: {
publicPath: '/dist/',
},
optimization: {
minimize: true,
minimizer: [new TerserJSPlugin({
terserOptions: {
extractComments: 'all',
compress: {
drop_console: true
}
}
}), new OptimizeCSSAssetsPlugin({})],
},
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
}
}
},
{
test: /\.(sa|sc|c)ss$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
},
'css-loader?',
'postcss-loader',
'resolve-url-loader',
'sass-loader'
],
}
]
},
plugins
});
提前致谢。干杯