【发布时间】:2018-01-15 16:08:00
【问题描述】:
我尝试使用 webpack2 运行我们的 ASP.NET MVC 项目。作为第一步,我使用 ExtractTextPlugin 设置 webpack2。
运行 webpack watch 时,我可以看到捆绑的 css 文件得到了更新。 但是,如果我使用 IISExpress 运行项目并运行 webpack watch,即使文件已更改,浏览器也不会获取最新更改。
验证如果我关闭 webpack watch 并刷新浏览器,那么我可以在浏览器中看到这些变化。
我在没有 webpack 开发服务器的情况下运行,这里是 webpack.config.js:
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const path = require('path');
module.exports = env => {
return {
entry: {
"main": "./static/entry.js",
"component": path.resolve(__dirname, "../component/static/bundle.js")
},
output: {
path: path.resolve(__dirname, "./static/dist/scripts"),
filename: "[name].index.js"
},
module: {
rules: [
{
test: /\.scss$/,
exclude: /node_modules/,
use:ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: 'css-loader',
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [
path.resolve(__dirname, './default.css'),
path.resolve(__dirname, './normalize.css')
]
}
}
]
})
},
{ test: /\.js$/, loader: 'babel-loader', exclude: /node_modules/ },
{ test: /\.ts$/, loader: 'babel-loader', exclude: /node_modules/ }
]
},
plugins: [
new webpack.ProvidePlugin({
$: path.resolve(__dirname, './node_modules/jquery/src/jquery'),
jQuery: path.resolve(__dirname, './node_modules/jquery/src/jquery'),
moment: path.resolve(__dirname, './node_modules/moment/moment')
}),
new ExtractTextPlugin({
filename: "../style/[name].style.css",
allChunks: true
}),
new webpack.optimize.UglifyJsPlugin({
minimize: true,
compress: {
warnings: false
}
})
]
}
};
问题一直存在,我不知道会发生什么,请帮忙。
【问题讨论】:
标签: asp.net-mvc webpack webpack-2 webpack-style-loader