2020-12-22 04:25:07 -05:00
|
|
|
const HTMLWebpackPlugin = require('html-webpack-plugin');
|
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
2021-03-06 12:56:45 -05:00
|
|
|
// const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
2020-12-22 04:25:07 -05:00
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
|
|
const webpack = require('webpack');
|
2021-03-06 12:56:45 -05:00
|
|
|
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
|
2020-12-22 04:25:07 -05:00
|
|
|
const { merge } = require('webpack-merge');
|
|
|
|
|
|
|
|
const env = require('../config/env');
|
|
|
|
|
|
|
|
const getPackageJson = require('./getPackageJson');
|
|
|
|
const baseConfig = require('./webpack.config');
|
|
|
|
|
|
|
|
const { version, name, license } = getPackageJson('version', 'name', 'license');
|
|
|
|
|
|
|
|
const banner = `
|
|
|
|
Name: [name]
|
|
|
|
Generated on: ${Date.now()}
|
|
|
|
Package: ${name}
|
|
|
|
Version: v${version}
|
|
|
|
License: ${license}
|
2021-03-06 12:56:45 -05:00
|
|
|
https://www.verdaccio.org
|
2020-12-22 04:25:07 -05:00
|
|
|
`;
|
|
|
|
|
|
|
|
const prodConf = {
|
2021-03-06 12:56:45 -05:00
|
|
|
mode: 'development',
|
|
|
|
devtool: 'inline-cheap-module-source-map',
|
2020-12-22 04:25:07 -05:00
|
|
|
|
|
|
|
entry: {
|
2021-09-08 12:06:37 -05:00
|
|
|
main: ['whatwg-fetch', `${env.SRC_ROOT}/index.tsx`],
|
2020-12-22 04:25:07 -05:00
|
|
|
},
|
|
|
|
|
|
|
|
module: {
|
|
|
|
rules: [],
|
|
|
|
},
|
|
|
|
|
|
|
|
plugins: [
|
|
|
|
new webpack.DefinePlugin({
|
|
|
|
__DEBUG__: false,
|
|
|
|
'process.env.NODE_ENV': '"production"',
|
|
|
|
__APP_VERSION__: `"${version}"`,
|
|
|
|
}),
|
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
// Options similar to the same options in webpackOptions.output
|
|
|
|
// both options are optional
|
|
|
|
filename: '[name].[contenthash].css',
|
|
|
|
chunkFilename: '[id].[contenthash].css',
|
|
|
|
}),
|
2021-03-06 12:56:45 -05:00
|
|
|
// FIXME: @deprecated remove
|
2020-12-22 04:25:07 -05:00
|
|
|
new HTMLWebpackPlugin({
|
|
|
|
title: 'ToReplaceByTitle',
|
|
|
|
__UI_OPTIONS: 'ToReplaceByVerdaccioUI',
|
|
|
|
scope: 'ToReplaceByScope',
|
|
|
|
basename: 'ToReplaceByPrefix',
|
|
|
|
logo: 'ToReplaceByLogo',
|
|
|
|
primary_color: 'ToReplaceByPrimaryColor',
|
|
|
|
filename: 'index.html',
|
|
|
|
favicon: `${env.SRC_ROOT}/template/favicon.ico`,
|
|
|
|
version_app: 'ToReplaceByVersion',
|
|
|
|
template: `${env.SRC_ROOT}/template/index.html`,
|
|
|
|
debug: false,
|
|
|
|
inject: true,
|
|
|
|
}),
|
2021-03-06 12:56:45 -05:00
|
|
|
new WebpackManifestPlugin({
|
|
|
|
removeKeyHash: true,
|
|
|
|
}),
|
2020-12-22 04:25:07 -05:00
|
|
|
new webpack.BannerPlugin(banner),
|
|
|
|
],
|
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
2021-03-06 12:56:45 -05:00
|
|
|
minimizer: [new TerserPlugin()],
|
2020-12-22 04:25:07 -05:00
|
|
|
},
|
|
|
|
performance: {
|
|
|
|
hints: 'warning',
|
|
|
|
maxEntrypointSize: 512000,
|
|
|
|
maxAssetSize: 512000,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = merge(baseConfig, prodConf);
|