1
0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-11-13 03:35:52 +01:00
verdaccio/tools/webpack.prod.config.babel.js

61 lines
1.7 KiB
JavaScript
Raw Normal View History

const webpack = require('webpack');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const UglifyJsWebpackPlugin = require('uglifyjs-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const baseConfig = require('./webpack.config');
const env = require('../src/config/env');
const _ = require('lodash');
const merge = require('webpack-merge');
2018-01-28 18:28:03 +01:00
import getPackageVersion from './getPackageVersion';
const prodConf = {
mode: 'production',
entry: {
main: ['babel-polyfill', 'whatwg-fetch', `${env.SRC_ROOT}/webui/src/index.js`],
},
module: {
rules: [],
},
plugins: [
new webpack.DefinePlugin({
2018-02-19 19:29:14 +01:00
__DEBUG__: false,
'process.env.NODE_ENV': '"production"',
2018-02-19 19:29:14 +01:00
__APP_VERSION__: `"${getPackageVersion()}"`,
}),
new MiniCssExtractPlugin({
filename: 'style.[contenthash].css',
}),
new HTMLWebpackPlugin({
title: 'ToReplaceByTitle',
filename: 'index.html',
favicon: `${env.SRC_ROOT}/webui/template/favicon.ico`,
verdaccioURL: 'ToReplaceByVerdaccio',
template: `${env.SRC_ROOT}/webui/template/index.html`,
2017-07-06 16:42:36 +02:00
debug: false,
inject: true,
}),
],
optimization: {
minimizer: [
new UglifyJsWebpackPlugin({
sourceMap: true,
}),
new OptimizeCSSAssetsPlugin({}),
],
},
};
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);