DEBUG is always false in production mode. Somehow it doesn’t put the “debugger” keyword in this case.
Function:
update: function(){
if(this.__requireSnapshot){
debugger
if(!DEBUG){
location.reload();
}
};
// Script to check if the planets are correct
// _.sortBy(data.logicPlanetStore.getInBlockId(0), '_id').forEach(function(p){console.log(p._id, p.units, p.owner.username)})
if(this.__requireUndoUpTo !== void 0){
this.undo(this.__requireUndoUpTo);
this.__requireUndoUpTo = void 0;
}
this.applyAllChanges();
},
Minified:
update: function() {
this.__requireSnapshot && location.reload(), void 0 !== this.__requireUndoUpTo && (this.undo(this.__requireUndoUpTo), this.__requireUndoUpTo = void 0), this.applyAllChanges()
}
Gulp file:
gulp.task("webpack:build", ['clean-dist'], function(callback) {
// modify some webpack config options
var myConfig = Object.create(webpackConfig);
myConfig.profile = true;
myConfig.resolve.alias.phaserUnFixed = "nodeModules/phaser/build/custom/phaser-arcade-physics.min.js";
myConfig.resolve.alias.react = "nodeModules/react/dist/react-with-addons.min.js";
myConfig.resolve.alias.lodash = "nodeModules/lodash/dist/lodash.compat.min.js";
myConfig.resolve.alias.moment = "nodeModules/moment/min/moment.min.js";
myConfig.custom.DEBUG = false;
// Try min files first (From: https://github.com/webpack/webpack/issues/615)
myConfig.resolve.extensions.splice(1, 0, ".min.js");
myConfig.plugins = myConfig.plugins.concat(
new webpack.DefinePlugin({
"process.env": {
// This has effect on the react lib size
"NODE_ENV": JSON.stringify("production")
}
}),
new webpack.optimize.OccurenceOrderPlugin({
preferEntry: true
}),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap : false,
compress : true,
exclude : './src/server'
}),
// Renders stats.json in dist
function() {
this.plugin("done", function(stats) {
var jsonStats = stats.toJson({
chunkModules: true,
});
// Analyze here: http://webpack.github.io/analyse/
require("fs").writeFileSync(path.join(__dirname, "dist", "stats.json"), JSON.stringify(jsonStats));
});
}
);
// run webpack
webpack(myConfig, function(err, stats) {
if(err) throw new gutil.PluginError("webpack:build", err);
gutil.log("[webpack:build]", stats.toString({
colors: true
}));
// Copy image in preloader
var mkpath = require('mkpath');
var image = 'Bit_Planets_symbol_white.png';
var path = '/assets/images/brand/Logo/'
var distPath = './dist' + path;
var srcPath = './src' + path;
mkpath.sync(distPath, 0700);
var fs = require('fs');
fs.createReadStream(srcPath+image).pipe(fs.createWriteStream(distPath+image));
// Not used for now. But would delete the .js file related to the .css generated.
gulp.start('clean-extra-css-js', callback);
});
});
I think this is the only relevant code for webpack:
module.exports.plugins = [
new ExtractTextPlugin("[chunkhash].css", {
allChunks: true
}),
new HtmlWebpackPlugin({
// templateContent: makeIndexHtml()
template: 'src/assets/index.html',
custom: module.exports.custom
})
]
try
Note: for Webpack 4 you will need this format: