为什么我的webpack配置无法观看
scss
文件?
如果我显式地将文件添加到
entry
然后它开始工作,创建css文件。这是个好的做法吗?
/// <binding ProjectOpened='Watch - Development' />
"use strict";
const path = require('path');
const webpack = require('webpack');
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
module.exports = {
watch: true,
entry: {
app: './src/scripts/app.js',
People: './Views/People/Index.cshtml.js',
Service: './Views/Service/Index.cshtml.js',
sass: './src/sass/app.scss' // <- this should explicitly stated
},
plugins: [
new MiniCssExtractPlugin({
path: path.join(__dirname, '/wwwroot/css/'),
filename: 'app.css',
})
],
output: {
publicPath: "/js/",
path: path.join(__dirname, '/wwwroot/js/'),
filename: '[name].bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /(node_modules)/,
query: {
presets: ['es2015']
}
},
{
test: /\.ts$/,
exclude: /node_modules|vue\/src/,
loader: "ts-loader",
options: {
appendTsSuffixTo: [/\.vue$/]
}
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
{ loader: 'css-loader', options: { url: false, sourceMap: true } },
{ loader: 'sass-loader', options: { sourceMap: true } }
]
},
{
test: /\.(png|jpg|gif)$/,
use: {
loader: 'url-loader',
options: {
limit: 8192
}
}
},
{
test: /\.vue$/,
loader: 'vue-loader',
}
]
},
resolve: {
alias: {
vue: 'vue/dist/vue.js'
},
extensions: ['.js', '.vue']
}
};