diff options
author | crupest <crupest@outlook.com> | 2020-07-26 15:02:55 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-07-26 15:02:55 +0800 |
commit | b78d21a524f7a11ad29b4bd230f23825f80c3ed7 (patch) | |
tree | 88bfe8d4c5298f61a90c501933784885ec9ce77f /Timeline/ClientApp/webpack.config.prod.js | |
parent | 886ab2a222bc503156542988edc7be5062f6e7b1 (diff) | |
download | timeline-b78d21a524f7a11ad29b4bd230f23825f80c3ed7.tar.gz timeline-b78d21a524f7a11ad29b4bd230f23825f80c3ed7.tar.bz2 timeline-b78d21a524f7a11ad29b4bd230f23825f80c3ed7.zip |
Merge front end repo
Diffstat (limited to 'Timeline/ClientApp/webpack.config.prod.js')
-rw-r--r-- | Timeline/ClientApp/webpack.config.prod.js | 84 |
1 files changed, 84 insertions, 0 deletions
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;
|