UNPKG

@mongodb-js/mongodb-ui-components

Version:

A collection of frequently used functional UI components found on mongodb properties

75 lines (70 loc) 1.71 kB
const path = require('path') const webpack = require('webpack') const UglifyJSPlugin = require('uglifyjs-webpack-plugin') const __dev__ = process.env.NODE_ENV === 'development' const components = [ 'nav', 'footer' ] const config = components.map(component => ({ mode: process.env.NODE_ENV, entry: { 'index': [ `./src/${component}/index.js`, `./src/${component}/standalone.js` ] }, module: { rules: [ { test: /.js$/, exclude: /node_modules/, use: { loader: 'babel-loader', options: { plugins: [ ['transform-react-jsx', {pragma: 'h'}], 'transform-strict-mode' ] } } } ] }, output: { path: path.join(__dirname, 'public', component), filename: '[name].js' }, plugins: [ new webpack.optimize.ModuleConcatenationPlugin(), new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), '__dev__': __dev__ }) ].concat(__dev__ ? [] : new UglifyJSPlugin({ parallel: true, uglifyOptions: { ecma: 5, warnings: true, compress: { drop_console: true, ecma: 5, keep_infinity: true, // investigate toplevel: true, passes: 2, // Some code runs faster in the Chrome V8 engine if this option is disabled reduce_funcs: false } } })) })) const report = (err, stats) => { if (err) console.error(err) if (stats) console.log(stats.toString({ chunks: false, colors: true })) } if (__dev__) { webpack(config).watch({ignored: /node_modules/}, report) } else { webpack(config).run(report) }