Skip to content

Instantly share code, notes, and snippets.

@a1exlism
Last active March 3, 2018 07:52
Show Gist options
  • Save a1exlism/2daf1ce6a2b6f830e22247494ec1f302 to your computer and use it in GitHub Desktop.
Save a1exlism/2daf1ce6a2b6f830e22247494ec1f302 to your computer and use it in GitHub Desktop.
/* package.json */
{
/* add --mode in webpack4.x */
"scripts": {
"dev": "cross-env DEBUG=true webpack-dev-server --open",
},
/* ... */
}
document.write('<h1>Hello World</h1>');
if (__DEV__) {
document.write(new Date());
}
const webpack = require('webpack');
let devFlagPlugin = new webpack.DefinePlugin({
__DEV__: JSON.stringify(JSON.parse(process.env.DEBUG || 'false'))
});
module.exports = {
entry: './main.js',
output: {
filename: 'bundle.js'
},
plugins: [devFlagPlugin]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment