1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/packages/plugins/ui-theme/tools/webpack.prod.config.babel.js
Juan Picado 558d78f32a feat: flexible user interface generator (#2070)
* feat: flexible template generator and manifest

* chore: add changeset

* chore: restore dep

* chore: add docs

* chore: update snapshots

* chore: update docker examples for v5

* chore: refactor web module

* chore: format

* chore: refactor web api endpoints

* test: add test for user login web

* chore: refactor endpoints

* chore: fix merge

* chore: fix merge

* Update ci.yml

* chore: test

* chore: add static

* chore: update script

* chore: fix e2e

* chore: fix method

* docs: update v5 relative docker example

* chore: update html render

* chore: update style

* Update .prettierignore

* chore: update changeset

* chore: use pnpm6 on run test

temporary ci

* chore: drop node 16 for pnpm 6

* chore: update ci

* chore: update ci

* chore: update ci

* chore: update ci

* chore: remove circle ci

* chore: better url prefix handling

* chore: format code

* chore: remove test node 10

* docs: add docker v5 relative revers proxy example

* chore: use base html tag

* chore: update test
2021-04-09 17:54:38 +02:00

92 lines
2.6 KiB
JavaScript

const HTMLWebpackPlugin = require('html-webpack-plugin');
const _ = require('lodash');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');
const webpack = require('webpack');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
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}
https://www.verdaccio.org
`;
const prodConf = {
mode: 'development',
devtool: 'inline-cheap-module-source-map',
entry: {
main: ['@babel/polyfill', 'whatwg-fetch', `${env.SRC_ROOT}/index.tsx`],
},
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',
}),
// FIXME: @deprecated remove
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`,
verdaccioURL: 'ToReplaceByVerdaccio',
version_app: 'ToReplaceByVersion',
template: `${env.SRC_ROOT}/template/index.html`,
debug: false,
inject: true,
}),
new WebpackManifestPlugin({
removeKeyHash: true,
}),
new webpack.BannerPlugin(banner),
],
optimization: {
minimize: true,
minimizer: [new TerserPlugin()],
},
performance: {
hints: 'warning',
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
};
prodConf.module.rules = baseConfig.module.rules
.filter(
(loader) =>
Array.isArray(loader.use) && loader.use.find((v) => /css/.test(v.loader.split('-')[0]))
)
.forEach((loader) => {
loader.use = [MiniCssExtractPlugin.loader].concat(_.tail(loader.use));
});
module.exports = merge(baseConfig, prodConf);