Configure webpack to poll for changes in development (#5040)
* Configure webpack to poll for changes in development Vagrant on Linux/macOS hosts shared files via NFS, which doens't support inotify-based watching of files. This tweak makes webpack check for changes every second, and rebuild if necessary. This removes the need to restart Foreman every time a frontend file changes. Note that rebuilding is still a relatively lengthy process. The polling frequency can be changed to taste. * Only poll in Vagrant This tests for the presence of the VAGRANT environment variable to determine whether or not we're in Vagrant. It is set in .env.vagrant, which is set up to be included in the Vagrantfile.pull/165/head
parent
d40c9140e8
commit
2076c557c9
|
@ -4,6 +4,17 @@ const merge = require('webpack-merge');
|
||||||
const sharedConfig = require('./shared.js');
|
const sharedConfig = require('./shared.js');
|
||||||
const { settings, output } = require('./configuration.js');
|
const { settings, output } = require('./configuration.js');
|
||||||
|
|
||||||
|
const watchOptions = {
|
||||||
|
ignored: /node_modules/,
|
||||||
|
};
|
||||||
|
|
||||||
|
if (process.env.VAGRANT) {
|
||||||
|
// If we are in Vagrant, we can't rely on inotify to update us with changed
|
||||||
|
// files, so we must poll instead. Here, we poll every second to see if
|
||||||
|
// anything has changed.
|
||||||
|
watchOptions.poll = 1000;
|
||||||
|
}
|
||||||
|
|
||||||
module.exports = merge(sharedConfig, {
|
module.exports = merge(sharedConfig, {
|
||||||
devtool: 'cheap-module-eval-source-map',
|
devtool: 'cheap-module-eval-source-map',
|
||||||
|
|
||||||
|
@ -26,8 +37,6 @@ module.exports = merge(sharedConfig, {
|
||||||
headers: { 'Access-Control-Allow-Origin': '*' },
|
headers: { 'Access-Control-Allow-Origin': '*' },
|
||||||
historyApiFallback: true,
|
historyApiFallback: true,
|
||||||
disableHostCheck: true,
|
disableHostCheck: true,
|
||||||
watchOptions: {
|
watchOptions: watchOptions,
|
||||||
ignored: /node_modules/,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue