* ci: test docs-publish * Specify to use prod * Babel should transpile with env set by webpack * chore: production defaults to true; set in --env.production by cli * Remove lingering merge issue * Add minimification plugins * Need relative URLs to find root assets * Default public url to forward slash in define plugin * Don't wrap w/ react-hot-loader if we're building for production * No need to log extensions * Minimize using terser; and minimize css * Import redux from es; this bypasses commonjs as import and fixes our "production build" warning * Split commone webpack build for now to test hotfix * postfix slash * undefined safe env access * Try to fix node_env prod issue w/ redux * Set NODE_ENV production for all prod builds * Syntax error * nix tests * Increase max amount of available memory * Don't run bundle analyzer by default * fix: asset resolution when at non-root route
70 lines
1.7 KiB
JavaScript
70 lines
1.7 KiB
JavaScript
const path = require('path');
|
|
const merge = require('webpack-merge');
|
|
const webpack = require('webpack');
|
|
const webpackCommon = require('./../../../.webpack/webpack.common.js');
|
|
//
|
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
|
// const
|
|
const SRC_DIR = path.join(__dirname, '../src');
|
|
const DIST_DIR = path.join(__dirname, '../dist');
|
|
|
|
module.exports = (env, argv) => {
|
|
const commonConfig = webpackCommon(env, argv, { SRC_DIR, DIST_DIR });
|
|
|
|
return merge(commonConfig, {
|
|
// https://webpack.js.org/configuration/mode/#mode-production
|
|
mode: 'production',
|
|
entry: {
|
|
bundle: `${SRC_DIR}/index-umd.js`,
|
|
},
|
|
devtool: 'source-map',
|
|
stats: {
|
|
colors: true,
|
|
hash: true,
|
|
timings: true,
|
|
assets: true,
|
|
chunks: false,
|
|
chunkModules: false,
|
|
modules: false,
|
|
children: false,
|
|
warnings: true,
|
|
},
|
|
optimization: {
|
|
minimize: true,
|
|
sideEffects: true,
|
|
},
|
|
output: {
|
|
path: DIST_DIR,
|
|
library: 'ohifViewer',
|
|
libraryTarget: 'umd',
|
|
filename: 'index.umd.js',
|
|
},
|
|
/**
|
|
* For CommonJS, we want to bundle whatever font we've landed on. This allows
|
|
* us to reduce the number of script-tags we need to specify for simple use.
|
|
*
|
|
* PWA will grab these externally to reduce bundle size (think code split),
|
|
* and cache the grab using service-worker.
|
|
*/
|
|
module: {
|
|
rules: [
|
|
{
|
|
test: /\.(ttf|eot|woff|woff2)$/i,
|
|
use: [
|
|
{
|
|
loader: 'file-loader',
|
|
options: {
|
|
name: '[name].[ext]',
|
|
},
|
|
},
|
|
],
|
|
},
|
|
],
|
|
},
|
|
plugins: [
|
|
// Clean output.path
|
|
new CleanWebpackPlugin(),
|
|
],
|
|
});
|
|
};
|