You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# webpack.development.config.js
'use strict';
var webpack = require('webpack')
var _ = require('lodash')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin
var baseConfig = require('./webpack.base.config')
var nodeEnv = 'development'
var developmentConfig = {
debug: true,
output: { filename: '[hash].app.js' },
devtool: 'cheap-module-eval-source-map',
plugins: [
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(nodeEnv) }),
new webpack.optimize.OccurenceOrderPlugin(),
new ExtractTextPlugin('[hash].app.css'),
new StatsWriterPlugin({
filename: 'frontend.json',
fields: null,
transform: function (data) {
return JSON.stringify({ hash: data.hash, node_env: nodeEnv }, null, 2);
}
})
]
}
module.exports = _.merge({}, baseConfig, developmentConfig)
# webpack.production.config.js
'use strict';
var webpack = require('webpack')
var _ = require('lodash')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin
var CompressionPlugin = require('compression-webpack-plugin');
var baseConfig = require('./webpack.base.config')
var nodeEnv = 'production'
var productionConfig = {
debug: false,
output: { filename: '[hash].app.min.js' },
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(nodeEnv) }),
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compressor: {
screw_ie8: true,
pure_getters: true,
unsafe: true,
unsafe_comps: true,
warnings: false
},
output: {
comments: false
},
// exclude: [/\.min\.js$/gi]
}),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0
}),
new ExtractTextPlugin('[hash].app.min.css'),
new StatsWriterPlugin({
filename: 'frontend.json',
fields: null,
transform: function (data) {
return JSON.stringify({ hash: data.hash, node_env: nodeEnv }, null, 2);
}
}),
new webpack.IgnorePlugin(/^\.\/locale$/, [/moment$/])
]
}
module.exports = _.merge({}, baseConfig, productionConfig)
# settings.py
def get_frontend_metadata(code_dir):
"""Return the frontend metadata for use in context processors."""
with io.open(os.path.join(code_dir, 'static', 'frontend.json')) as f:
return json.loads(f.read())
FRONTEND_METADATA = get_frontend_metadata(REPO_DIR)
We have fixed file name for static resources e.g. bundle.js, main.css
It is better to use hash values for these resources like bundle.[hash].js
Implementation Details [provided by @pwalsh ]
The text was updated successfully, but these errors were encountered: