From b78d21a524f7a11ad29b4bd230f23825f80c3ed7 Mon Sep 17 00:00:00 2001 From: crupest Date: Sun, 26 Jul 2020 15:02:55 +0800 Subject: Merge front end repo --- Timeline/ClientApp/webpack.config.prod.js | 84 +++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 Timeline/ClientApp/webpack.config.prod.js (limited to 'Timeline/ClientApp/webpack.config.prod.js') diff --git a/Timeline/ClientApp/webpack.config.prod.js b/Timeline/ClientApp/webpack.config.prod.js new file mode 100644 index 00000000..d0c72381 --- /dev/null +++ b/Timeline/ClientApp/webpack.config.prod.js @@ -0,0 +1,84 @@ +const path = require('path'); +const { CleanWebpackPlugin } = require('clean-webpack-plugin'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); +const CopyPlugin = require('copy-webpack-plugin'); +const WorkboxPlugin = require('workbox-webpack-plugin'); +const PnpWebpackPlugin = require('pnp-webpack-plugin'); + +const { commonRules, htmlCommonConfig } = require('./webpack.common'); + +const config = { + entry: ['./src/app/index.tsx', './src/app/service-worker.tsx'], + mode: 'production', + devtool: 'source-map', + module: { + rules: [ + ...commonRules, + { + test: /\.ts(x?)$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader', + }, + { + loader: 'ts-loader', + }, + ], + }, + { + test: /\.js(x?)$/, + exclude: /node_modules/, + use: [ + { + loader: 'babel-loader', + }, + ], + }, + ], + }, + resolve: { + extensions: ['*', '.js', '.jsx', '.ts', '.tsx'], + plugins: [PnpWebpackPlugin], + }, + resolveLoader: { + plugins: [PnpWebpackPlugin.moduleLoader(module)], + }, + optimization: { + runtimeChunk: 'single', + splitChunks: { + chunks: 'all', + cacheGroups: { + vendor: { + test: /[\\/]node_modules[\\/]/, + name: 'vendors', + chunks: 'all', + }, + }, + }, + }, + output: { + path: path.resolve(__dirname, 'dist/'), + filename: '[name].[hash].js', + chunkFilename: '[name].[hash].js', + publicPath: '/', + }, + plugins: [ + new CleanWebpackPlugin(), + new HtmlWebpackPlugin(htmlCommonConfig), + new CopyPlugin({ + patterns: [ + { + from: path.resolve(__dirname, 'public/'), + to: path.resolve(__dirname, 'dist/'), + }, + ], + }), + new WorkboxPlugin.InjectManifest({ + swSrc: './src/sw/sw.ts', + maximumFileSizeToCacheInBytes: 15000000, + }), + ], +}; + +module.exports = config; -- cgit v1.2.3