Private
Public Access
1
0
Files
MineSeeker/webpack-prod.config.js

58 lines
1.5 KiB
JavaScript

'use strict';
var webpack = require("webpack");
process.env.NODE_ENV = 'production';
var isProd = (process.env.NODE_ENV === 'production');
/**
* Conditionally return a list of plugins to use based on the current environment.
* Repeat this pattern for any other config key (ie: loaders, etc).
* @returns {Array}
*/
function getPlugins() {
var plugins = [];
/**
* Always expose NODE_ENV to webpack, you can now use `process.env.NODE_ENV`
* inside your code for any environment checks; UglifyJS will automatically
* drop any unreachable code.
*/
plugins.push(new webpack.DefinePlugin({
'process.env': {
'NODE_ENV': JSON.stringify(process.env.NODE_ENV)
}
}));
/** Conditionally add plugins for Production builds. */
if (isProd) {
plugins.push(new webpack.optimize.UglifyJsPlugin());
} else {
/** Conditionally add plugins for Development */
}
return plugins;
}
const config = module.exports = {
entry: './web/bundles/mineseeker/js/mine-seeker.js',
output: {
path: './src/Mine/SeekerBundle/Resources/public/js',
filename: 'index.min.js'
},
module: {
loaders: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
query: {
presets: ['es2015', 'react']
}
}
]
},
plugins: getPlugins()
};
module.exports = config;