2020-01-25 14:11:34 +05:30
|
|
|
const cssnano = require('cssnano');
|
2020-01-28 13:00:39 +05:30
|
|
|
const fastGlob = require('fast-glob');
|
|
|
|
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
|
2020-01-25 14:11:34 +05:30
|
|
|
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
|
|
|
|
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
|
|
|
|
const PostCSSPresetEnv = require('postcss-preset-env');
|
2020-01-28 13:00:39 +05:30
|
|
|
const PostCSSSafeParser = require('postcss-safe-parser');
|
|
|
|
const TerserPlugin = require('terser-webpack-plugin');
|
|
|
|
const VueLoaderPlugin = require('vue-loader/lib/plugin');
|
|
|
|
const { resolve, parse } = require('path');
|
|
|
|
const { SourceMapDevToolPlugin } = require('webpack');
|
|
|
|
|
|
|
|
const themes = {};
|
|
|
|
for (const path of fastGlob.sync(resolve(__dirname, 'web_src/less/themes/*.less'))) {
|
|
|
|
themes[parse(path).name] = [path];
|
|
|
|
}
|
2019-11-13 20:22:13 +05:30
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
mode: 'production',
|
|
|
|
entry: {
|
2020-01-28 13:00:39 +05:30
|
|
|
index: [
|
|
|
|
resolve(__dirname, 'web_src/js/index.js'),
|
|
|
|
resolve(__dirname, 'web_src/less/index.less'),
|
|
|
|
],
|
|
|
|
swagger: [
|
|
|
|
resolve(__dirname, 'web_src/js/swagger.js'),
|
|
|
|
],
|
|
|
|
jquery: [
|
|
|
|
resolve(__dirname, 'web_src/js/jquery.js'),
|
|
|
|
],
|
|
|
|
...themes,
|
2019-11-13 20:22:13 +05:30
|
|
|
},
|
2020-01-14 23:32:08 +05:30
|
|
|
devtool: false,
|
2019-11-13 20:22:13 +05:30
|
|
|
output: {
|
2020-01-28 13:00:39 +05:30
|
|
|
path: resolve(__dirname, 'public'),
|
2020-01-25 14:11:34 +05:30
|
|
|
filename: 'js/[name].js',
|
|
|
|
chunkFilename: 'js/[name].js',
|
2019-11-13 20:22:13 +05:30
|
|
|
},
|
|
|
|
optimization: {
|
|
|
|
minimize: true,
|
2020-01-25 14:11:34 +05:30
|
|
|
minimizer: [
|
|
|
|
new TerserPlugin({
|
|
|
|
sourceMap: true,
|
|
|
|
extractComments: false,
|
|
|
|
terserOptions: {
|
|
|
|
output: {
|
|
|
|
comments: false,
|
|
|
|
},
|
2019-11-18 03:09:06 +05:30
|
|
|
},
|
2020-01-25 14:11:34 +05:30
|
|
|
}),
|
|
|
|
new OptimizeCSSAssetsPlugin({
|
|
|
|
cssProcessor: cssnano,
|
|
|
|
cssProcessorOptions: {
|
|
|
|
parser: PostCSSSafeParser,
|
|
|
|
},
|
|
|
|
cssProcessorPluginOptions: {
|
|
|
|
preset: [
|
|
|
|
'default',
|
|
|
|
{
|
|
|
|
discardComments: {
|
|
|
|
removeAll: true,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
],
|
2019-11-13 20:22:13 +05:30
|
|
|
},
|
2019-11-15 03:09:51 +05:30
|
|
|
module: {
|
|
|
|
rules: [
|
2020-01-20 15:37:30 +05:30
|
|
|
{
|
|
|
|
test: /\.vue$/,
|
|
|
|
exclude: /node_modules/,
|
2020-01-25 14:11:34 +05:30
|
|
|
loader: 'vue-loader',
|
2020-01-20 15:37:30 +05:30
|
|
|
},
|
2019-11-15 03:09:51 +05:30
|
|
|
{
|
|
|
|
test: /\.js$/,
|
|
|
|
exclude: /node_modules/,
|
2020-01-22 12:05:29 +05:30
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: 'babel-loader',
|
|
|
|
options: {
|
|
|
|
presets: [
|
|
|
|
[
|
|
|
|
'@babel/preset-env',
|
|
|
|
{
|
|
|
|
useBuiltIns: 'usage',
|
|
|
|
corejs: 3,
|
2020-01-25 14:11:34 +05:30
|
|
|
},
|
|
|
|
],
|
2020-01-20 15:37:30 +05:30
|
|
|
],
|
2020-01-22 12:05:29 +05:30
|
|
|
plugins: [
|
|
|
|
[
|
|
|
|
'@babel/plugin-transform-runtime',
|
|
|
|
{
|
|
|
|
regenerator: true,
|
|
|
|
}
|
|
|
|
],
|
|
|
|
'@babel/plugin-proposal-object-rest-spread',
|
|
|
|
],
|
2020-01-25 14:11:34 +05:30
|
|
|
},
|
2020-01-22 12:05:29 +05:30
|
|
|
},
|
|
|
|
],
|
2019-11-18 03:09:06 +05:30
|
|
|
},
|
|
|
|
{
|
2020-01-28 13:00:39 +05:30
|
|
|
test: /\.(less|css)$/i,
|
2020-01-25 14:11:34 +05:30
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: MiniCssExtractPlugin.loader,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'css-loader',
|
|
|
|
options: {
|
2020-01-28 13:00:39 +05:30
|
|
|
importLoaders: 2,
|
|
|
|
url: false,
|
2020-01-25 14:11:34 +05:30
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: 'postcss-loader',
|
|
|
|
options: {
|
|
|
|
plugins: () => [
|
|
|
|
PostCSSPresetEnv(),
|
|
|
|
],
|
|
|
|
},
|
|
|
|
},
|
2020-01-28 13:00:39 +05:30
|
|
|
{
|
|
|
|
loader: 'less-loader',
|
|
|
|
},
|
2020-01-25 14:11:34 +05:30
|
|
|
],
|
2019-11-18 03:09:06 +05:30
|
|
|
},
|
2020-01-25 14:11:34 +05:30
|
|
|
],
|
2020-01-14 23:32:08 +05:30
|
|
|
},
|
|
|
|
plugins: [
|
2020-01-20 15:37:30 +05:30
|
|
|
new VueLoaderPlugin(),
|
2020-01-28 13:00:39 +05:30
|
|
|
// needed so themes don't generate useless js files
|
|
|
|
new FixStyleOnlyEntriesPlugin({
|
|
|
|
silent: true,
|
|
|
|
}),
|
2020-01-25 14:11:34 +05:30
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: 'css/[name].css',
|
|
|
|
chunkFilename: 'css/[name].css',
|
|
|
|
}),
|
2020-01-14 23:32:08 +05:30
|
|
|
new SourceMapDevToolPlugin({
|
2020-01-25 14:11:34 +05:30
|
|
|
filename: 'js/[name].js.map',
|
2020-01-14 23:32:08 +05:30
|
|
|
exclude: [
|
2020-01-25 14:11:34 +05:30
|
|
|
'js/gitgraph.js',
|
|
|
|
'js/jquery.js',
|
|
|
|
'js/swagger.js',
|
2020-01-14 23:32:08 +05:30
|
|
|
],
|
|
|
|
}),
|
|
|
|
],
|
|
|
|
performance: {
|
2020-01-21 23:02:33 +05:30
|
|
|
maxEntrypointSize: 512000,
|
|
|
|
maxAssetSize: 512000,
|
2020-01-14 23:32:08 +05:30
|
|
|
assetFilter: (filename) => {
|
2020-01-25 14:11:34 +05:30
|
|
|
return !filename.endsWith('.map') && filename !== 'js/swagger.js';
|
|
|
|
},
|
2020-01-14 23:32:08 +05:30
|
|
|
},
|
2020-01-22 12:05:29 +05:30
|
|
|
resolve: {
|
|
|
|
symlinks: false,
|
2020-01-25 14:11:34 +05:30
|
|
|
},
|
2019-11-13 20:22:13 +05:30
|
|
|
};
|