2017-08-08 90 views
0

我嘗試使用webpack2運行ASP.NET MVC項目。作爲第一步,我使用ExtractTextPlugin設置了webpack2。運行webpack手錶時,瀏覽器不會更改本地文件更改

運行webpack watch時,我可以看到捆綁的css文件得到更新。 但是,如果我使用IISExpress運行項目並且運行webpack watch,則即使文件已更改,瀏覽器也不會獲取最新更改。

驗證如果我關閉webpack手錶並刷新瀏覽器,那麼我可以在瀏覽器中看到這些更改。

我運行沒有的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$/, 
 
\t \t \t \t  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 
 
       } 
 
      }) 
 
    ] 
 

 
    } 
 

 
};

問題是恆定的,我不知道什麼可能已經發生了,請幫忙。

回答

0

我發現了這個問題的原因。

項目web.config緩存客戶端資源,禁用輸出緩存修復了問題。

<caching> 
    <outputCache enableOutputCache="false" /> 
</caching> 
相關問題