My project directory Structure is :
mcdist <build output folder>
- assets
index.html
- css
main.css
- js
app.js
lib.js
- ng-app
<all HTML Files>
- images
src
- images
1.png
2.png
- javascripts
- ng-app
- components
1.js
- directives
2.js
- filters
3.js
- stylesheets
1.scss
2.scss
index.html
app.js
node_modules
webpack.config.js
package.json
My webpack.config looks like this :
var path = require('path');
var webpack = require('webpack');
var config = {
entry: {
app: ['./app.js'],
lib: ['./lib.js']
},
output: {
path: path.join(__dirname, '/mcdist/assets/js/'),
filename: 'app.js',
publicPath: "/public/js/"
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: 'lib',
filename: 'lib.js',
minChunks: Infinity
}),
new webpack.NamedModulesPlugin()
],
devServer: {
proxy: [{
context: [
'/mcdist/api',
'/mcdist/appConfig',
'/mcdist/j_spring_security_logout'
],
target: 'http://localhost:8080',
secure: false
}],
port: 9000
}
};
module.exports = config
I run:
webpack-dev-server --inline
I create build folder 'mcdist' using npm command as :
"build:js": "uglifyjs mcdist/assets/js/app.js -m -o mcdist/assets/js/app.js",
My src/app.js looks like this :
require('./src/javascripts/ng-app/config/init-config.js');
require('./src/javascripts/ng-app/config/theme-config.js');
require('./src/javascripts/ng-app/components/dialog-message/dialog-message.service.js');
require('./src/javascripts/ng-app/components/footer/footer.controller.js');
require('./src/javascripts/ng-app/components/topbar/topbar.controller.js');
and many more files as list in require format in app.js
Now every time I make changes in HTML, JS files I need to create new build so changes get pushed to 'mcdist' folder (JS files gets concatenated and uglified in single app.js and all HTML files pushed to ng-app folder inside 'mcdist' folder.)
AND I've to RESTART WEBPACK dev server to see changes reflected.
This is very painful in local/development environment as changing small code needs build and restart, which is not the case with Grails application.
is there any way I can avoid restarting a server and just make changes to them hot-reloaded ? I've already tried running with --hot and --inline approaches but nothing had luck.
Help is most appreciated.