我一直在寻找试图找到如何设置.net core 3项目以使用webpack开发服务器来服务资产的时代。这将允许诸如热模块更换之类的事情。如果有人为完成此任务有一些样板,那就太好了!下面,我包括了我当前的开发webpack配置:
module.exports = {
mode: "development",
entry: {
app: "./wwwroot/src/js/app.js",
},
output: {
publicPath: "/dist/",
filename: "[name].bundle.js",
path: path.join(__dirname, "/wwwroot/dist/"),
},
optimization: {
splitChunks: {
chunks: "all",
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
chunks: "all",
},
},
},
},
plugins: [],
module: {
rules: [
{
test: /\.m?js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
plugins: ["@babel/plugin-transform-runtime"],
},
},
},
{
test: /\.scss$/,
use: ["style-loader", "css-loader", "sass-loader"],
},
{
test: require.resolve("jquery"),
use: [
{
loader: "expose-loader",
options: "jQuery",
},
{
loader: "expose-loader",
options: "$",
},
],
},
],
},
};