webpack-2: HMR , css and html browser is not work label:webpack-2
when I use webpack-dev-server@2 and HMR, (webpack@2 [email protected] [email protected])
my config.js:
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
const autoprefixer = require('autoprefixer');
const moment = require('moment');
module.exports = {
entry: {
app: './app.js',
vendor: 'moment',
},
output: {
path: path.resolve(__dirname, "build"),
publicPath: '/',
filename: 'scripts/main.js'
},
devServer: {
inline: true,
hot: true,
port: 8080,
contentBase: [
path.resolve(__dirname, './build/views/'),
],
},
module: {
rules: [{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
loader: 'css-loader',
fallbackLoader: 'style-loader'
}),
}, {
test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
loader: 'url-loader?limit=50000&name=[path][name].[ext]'
}, ]
},
plugins: [
new WriteFilePlugin({}),
new webpack.HotModuleReplacementPlugin(),
new webpack.LoaderOptionsPlugin({
options: {
postcss: [autoprefixer({ browsers: ['last 2 versions'] })],
},
}),
new webpack.LoaderOptionsPlugin({
debug: true
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor', // Specify the common bundle's name.
filename: 'scripts/[name].bundle.js'
}),
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery",
"window.jQuery": "jquery"
}),
new ExtractTextPlugin({
filename: 'styles/main.css',
disable: false,
allChunks: true
}),
new HtmlWebpackPlugin({
title: 'My App',
template: "./src/page/index.html",
filename: "./views/index.html",
}),
new HtmlWebpackPlugin({
template: "./src/page/login.html",
filename: "./views/login.html",
}),
],
watch: true,
watchOptions: {
ignored: "/node_modules/",
aggregateTimeout: 500,
poll: 500,
},
};
I use Command line mode such as
webpack-dev-server --inline --hot
When I change js file ,command line is tell me something has changed and the browser can reload. But when I change css or html file , command line tell me something has changed , but the browser do not reload , I want to know,which reason cause it;
i met the similar problem, but my problem is the webpack and browser will not recompile and reload after i change any file.
Please submit support requests and questions to StackOverflow using the tag [webpack]. StackOverflow is better suited for this kind of support. The issue tracker is for bug reports and feature discussions. See also our CONTRIBUTING guidelines.