From 93ce8560fa19c3a91de99643fdbbe4f895a47b84 Mon Sep 17 00:00:00 2001 From: crupest Date: Thu, 11 Jun 2020 17:27:15 +0800 Subject: feat(front): Service worker is coming! --- Timeline/ClientApp/webpack.config.dev.js | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'Timeline/ClientApp/webpack.config.dev.js') diff --git a/Timeline/ClientApp/webpack.config.dev.js b/Timeline/ClientApp/webpack.config.dev.js index 12b25253..7a38f2b6 100644 --- a/Timeline/ClientApp/webpack.config.dev.js +++ b/Timeline/ClientApp/webpack.config.dev.js @@ -2,12 +2,14 @@ const path = require('path'); const webpack = require('webpack'); const HtmlWebpackPlugin = require('html-webpack-plugin'); const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); +const CopyPlugin = require('copy-webpack-plugin'); const PnpWebpackPlugin = require('pnp-webpack-plugin'); +const WorkboxPlugin = require('workbox-webpack-plugin'); const { commonRules, htmlCommonConfig } = require('./webpack.common'); const config = { - entry: ['react-hot-loader/patch', './src/index.tsx'], + entry: ['react-hot-loader/patch', './src/app/index.tsx'], mode: 'development', devtool: 'eval-source-map', module: { @@ -53,7 +55,7 @@ const config = { publicPath: '/', }, devServer: { - contentBase: path.join(__dirname, 'public/'), + contentBase: false, host: '0.0.0.0', port: 3000, publicPath: 'http://localhost:3000/', @@ -65,8 +67,25 @@ const config = { ...htmlCommonConfig, devServer: 'http://localhost:3000', }), - new ForkTsCheckerWebpackPlugin(), + new CopyPlugin({ + patterns: [ + { + from: path.resolve(__dirname, 'public/'), + to: path.resolve(__dirname, 'dist/'), + }, + ], + }), + new ForkTsCheckerWebpackPlugin({ + tsconfig: './src/app/tsconfig.json', + }), + new ForkTsCheckerWebpackPlugin({ + tsconfig: './src/sw/tsconfig.json', + }), new webpack.HotModuleReplacementPlugin(), + new WorkboxPlugin.InjectManifest({ + swSrc: './src/sw/sw.ts', + maximumFileSizeToCacheInBytes: 15000000, + }), ], }; -- cgit v1.2.3