Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit bda57d32 authored by Zamil Majdy's avatar Zamil Majdy
Browse files

#140382397 #4 Add production webpack config

parent 118965f1
Branches
No related tags found
No related merge requests found
......@@ -14,34 +14,7 @@ module.exports = {
plugins: [
new webpack.HotModuleReplacementPlugin(),
new BundleTracker({filename: './webpack-stats.json'}),
// removes a lot of debugging code in React
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}}),
// keeps hashes consistent between compilations
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
warnings: false, // Suppress uglification warnings
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true
},
output: {
comments: false,
},
exclude: [/\.min\.js$/gi] // skip pre-minified libs
}),
new webpack.IgnorePlugin(/^\.\/locale$/, [/moment$/])
new BundleTracker({filename: './webpack-stats.json'})
],
module: {
......
var path = require("path")
var webpack = require('webpack')
var BundleTracker = require('webpack-bundle-tracker')
var CompressionPlugin = require('compression-webpack-plugin')
var config = require('./webpack.base.config.js')
module.exports = {
context: __dirname,
config.output.path = require('path').resolve('./assets/dist')
entry: './assets/js/index', // entry point of our app. assets/js/index.js should require other js modules and dependencies it needs
config.plugins = config.plugins.concat([
new BundleTracker({filename: './webpack-stats-prod.json'}),
output: {
path: path.resolve('./assets/bundles/'),
filename: "[name]-[hash].js",
},
// removes a lot of debugging code in React
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}}),
plugins: [
new webpack.HotModuleReplacementPlugin(),
new BundleTracker({filename: './webpack-stats.json'}),
// keeps hashes consistent between compilations
new webpack.optimize.OccurenceOrderPlugin(),
// removes a lot of debugging code in React
new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify('production')
}}),
// minifies your code
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
})
])
// keeps hashes consistent between compilations
new webpack.optimize.AggressiveMergingPlugin(),
new webpack.optimize.OccurrenceOrderPlugin(),
new webpack.optimize.DedupePlugin(),
new webpack.optimize.UglifyJsPlugin({
mangle: true,
compress: {
warnings: false, // Suppress uglification warnings
pure_getters: true,
unsafe: true,
unsafe_comps: true,
screw_ie8: true
},
output: {
comments: false,
},
exclude: [/\.min\.js$/gi] // skip pre-minified libs
}),
// Add a loader for JSX files
config.module.loaders.push(
{ test: /\.jsx?$/, exclude: /node_modules/, loader: 'babel' }
)
new webpack.IgnorePlugin(/^\.\/locale$/, [/moment$/]),
module.exports = config
new CompressionPlugin({
asset: "[path][query]",
algorithm: "gzip",
test: /\.js$|\.css$|\.html$/,
threshold: 10240,
minRatio: 0.8
})
],
module: {
loaders: [
{ test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader', // to transform JSX into JS
query:
{
presets:['react', 'es2015', 'stage-1']
}
}
],
},
resolve: {
modulesDirectories: ['node_modules', 'bower_components'],
extensions: ['', '.js', '.jsx']
},
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment