diff options
author | crupest <crupest@outlook.com> | 2020-08-24 01:20:37 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-08-24 01:20:37 +0800 |
commit | 2a36e7ce0febae1e04bec2bb8d92983dc32b71ba (patch) | |
tree | 8f9d11fcf6235366e6a1c699986199d9797d816a /Timeline/ClientApp/webpack.config.prod.js | |
parent | 50253f470c0fcce0ffd3d7257a1b4c0840c82cd1 (diff) | |
download | timeline-2a36e7ce0febae1e04bec2bb8d92983dc32b71ba.tar.gz timeline-2a36e7ce0febae1e04bec2bb8d92983dc32b71ba.tar.bz2 timeline-2a36e7ce0febae1e04bec2bb8d92983dc32b71ba.zip |
Migrate to webpack chain.
Diffstat (limited to 'Timeline/ClientApp/webpack.config.prod.js')
-rw-r--r-- | Timeline/ClientApp/webpack.config.prod.js | 96 |
1 files changed, 24 insertions, 72 deletions
diff --git a/Timeline/ClientApp/webpack.config.prod.js b/Timeline/ClientApp/webpack.config.prod.js index d0c72381..e3ef65e1 100644 --- a/Timeline/ClientApp/webpack.config.prod.js +++ b/Timeline/ClientApp/webpack.config.prod.js @@ -1,84 +1,36 @@ 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 = 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',
- },
- ],
- },
+config.mode('production');
+
+config
+ .entry('index')
+ .add(path.resolve(__dirname, 'src/app/service-worker.tsx'));
+
+config.devtool('source-map');
+
+config.plugin('clean').use(CleanWebpackPlugin);
+
+config.plugin('copy').use(CopyPlugin, [
+ {
+ patterns: [
{
- test: /\.js(x?)$/,
- exclude: /node_modules/,
- use: [
- {
- loader: 'babel-loader',
- },
- ],
+ from: path.resolve(__dirname, 'public/'),
+ to: path.resolve(__dirname, 'dist/'),
},
],
},
- 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: '/',
+]);
+
+config.plugin('workbox').use(WorkboxPlugin.InjectManifest, [
+ {
+ swSrc: path.resolve(__dirname, 'src/sw/sw.ts'),
+ maximumFileSizeToCacheInBytes: 15000000,
},
- 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;
+module.exports = config.toConfig();
|