2017-05-08 18:50:59 +00:00
|
|
|
/* global __dirname, process */
|
2017-05-08 17:06:54 +00:00
|
|
|
|
|
|
|
var path = require( 'path' ),
|
|
|
|
webpack = require( 'webpack' ),
|
2017-05-08 18:50:59 +00:00
|
|
|
PUBLIC_PATH = '/w/extensions/Popups',
|
|
|
|
isProduction = process.env.NODE_ENV === 'production',
|
|
|
|
reduxPath,
|
|
|
|
reduxThunkPath,
|
|
|
|
conf;
|
2017-01-26 21:31:41 +00:00
|
|
|
|
2017-05-08 18:50:59 +00:00
|
|
|
reduxPath = isProduction ?
|
|
|
|
'node_modules/redux/dist/redux.min.js' :
|
|
|
|
'node_modules/redux/dist/redux.js';
|
|
|
|
|
|
|
|
reduxThunkPath = isProduction ?
|
|
|
|
'node_modules/redux-thunk/dist/redux-thunk.min.js' :
|
|
|
|
'node_modules/redux-thunk/dist/redux-thunk.js';
|
|
|
|
|
|
|
|
conf = {
|
2017-01-26 21:31:41 +00:00
|
|
|
output: {
|
|
|
|
// The absolute path to the output directory.
|
2017-02-13 13:47:59 +00:00
|
|
|
path: path.resolve( __dirname, 'resources/dist' ),
|
2017-01-26 21:31:41 +00:00
|
|
|
devtoolModuleFilenameTemplate: PUBLIC_PATH + '/[resource-path]',
|
|
|
|
|
|
|
|
// Write each chunk (entries, here) to a file named after the entry, e.g.
|
|
|
|
// the "index" entry gets written to index.js.
|
2017-08-29 19:18:35 +00:00
|
|
|
filename: '[name].js',
|
|
|
|
// as we cannot serve .map files from production servers store map files
|
|
|
|
// with .json extension
|
|
|
|
sourceMapFilename: "[file].json"
|
2017-01-26 21:31:41 +00:00
|
|
|
},
|
|
|
|
entry: {
|
2017-02-13 14:02:18 +00:00
|
|
|
index: './src/index.js'
|
2017-01-26 21:31:41 +00:00
|
|
|
},
|
2017-03-03 10:14:37 +00:00
|
|
|
devtool: 'source-map',
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2017-05-08 18:50:59 +00:00
|
|
|
redux: path.resolve( __dirname, reduxPath ),
|
|
|
|
'redux-thunk': path.resolve( __dirname, reduxThunkPath )
|
2017-03-03 10:14:37 +00:00
|
|
|
}
|
2017-03-03 10:24:45 +00:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
// To generate identifiers that are preserved over builds, webpack supplies
|
|
|
|
// the NamedModulesPlugin (generates comments with file names on bundle)
|
|
|
|
// https://webpack.js.org/guides/caching/#deterministic-hashes
|
2017-10-11 21:19:39 +00:00
|
|
|
new webpack.NamedModulesPlugin()
|
2017-03-03 10:24:45 +00:00
|
|
|
]
|
2017-01-26 21:31:41 +00:00
|
|
|
};
|
2017-05-08 18:50:59 +00:00
|
|
|
|
|
|
|
// Production settings.
|
|
|
|
// Enable minification and dead code elimination with uglify. Define the
|
|
|
|
// global process.env.NODE_ENV so that libraries like redux and redux-thunk get
|
|
|
|
// development code trimmed.
|
|
|
|
// Enable minimize flags for webpack loaders and disable debug.
|
|
|
|
if ( isProduction ) {
|
|
|
|
conf.plugins = conf.plugins.concat( [
|
|
|
|
new webpack.LoaderOptionsPlugin( {
|
|
|
|
minimize: true,
|
|
|
|
debug: false
|
|
|
|
} ),
|
|
|
|
new webpack.DefinePlugin( {
|
|
|
|
'process.env': {
|
|
|
|
NODE_ENV: JSON.stringify( 'production' )
|
|
|
|
}
|
|
|
|
} ),
|
|
|
|
new webpack.optimize.UglifyJsPlugin( {
|
|
|
|
sourceMap: true,
|
|
|
|
comments: /@nomin/
|
|
|
|
} )
|
|
|
|
] );
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = conf;
|