12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- // webpack.config.js
- /* eslint-disable */
- const path = require('path')
- const webpack = require('webpack')
- const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
- const ENVIRONMENT = process.env.NODE_ENV
- const PRODUCTION = ENVIRONMENT === 'production'
- const SOURCEMAP = !PRODUCTION || process.env.SOURCEMAP
- const library = 'modularity-front' // << RENAME THIS <<
- const filename = PRODUCTION ? `${library}.min.js` : `${library}.js`
- const plugins = []
- if (PRODUCTION) {
- plugins.push(
- new webpack.DefinePlugin({
- 'process.env.NODE_ENV': JSON.stringify(ENVIRONMENT),
- }),
- new webpack.optimize.ModuleConcatenationPlugin()
- )
- }
- module.exports = {
- devtool: SOURCEMAP ? 'source-map' : 'none',
- entry: `${__dirname}/src/exports.js`, // << RENAME THIS <<
- externals: {
- 'react': 'react',
- 'react-dom': 'react-dom',
- },
- mode: PRODUCTION ? "production" : "development",
- module: {
- rules: [{
- test: /\.js$/,
- loader: 'babel-loader',
- exclude: /node_modules/,
- }],
- },
- output: {
- filename,
- library,
- path: `${__dirname}/lib`,
- libraryTarget: 'umd',
- umdNamedDefine: true,
- },
- optimization: {
- minimizer: [
- // we specify a custom UglifyJsPlugin here to get source maps in production
- new UglifyJsPlugin({
- cache: true,
- parallel: true,
- uglifyOptions: {
- compress: false,
- ecma: 6,
- mangle: true
- },
- sourceMap: true
- })
- ]
- },
- plugins
- }
|