|
| 1 | +const path = require('path') |
| 2 | +const webpack = require('webpack') |
| 3 | +const HtmlWebpackPlugin = require('html-webpack-plugin') |
| 4 | +const ForkTsCheckerWebpackPlugin = require("fork-ts-checker-webpack-plugin") |
| 5 | + |
| 6 | +const PORT = 4222; |
| 7 | +const HOST = 'http://localhost'; |
| 8 | +const URL = `${HOST}:${PORT}`; |
| 9 | + |
| 10 | +module.exports = { |
| 11 | + mode: 'development', |
| 12 | + entry: [ |
| 13 | + '../src/index.tsx' |
| 14 | + ], |
| 15 | + output: { |
| 16 | + filename: 'app.js', |
| 17 | + path: path.join(__dirname, '../dist'), |
| 18 | + publicPath: '' |
| 19 | + }, |
| 20 | + context: path.resolve(__dirname, '../src'), |
| 21 | + devtool: 'source-map', |
| 22 | + devServer: { |
| 23 | + stats: { |
| 24 | + cached: true, |
| 25 | + chunkModules: false, |
| 26 | + colors: true |
| 27 | + }, |
| 28 | + hot: true, |
| 29 | + compress: true, |
| 30 | + contentBase: path.resolve(__dirname, '../src'), |
| 31 | + port: PORT, |
| 32 | + publicPath: URL, |
| 33 | + historyApiFallback: true, |
| 34 | + }, |
| 35 | + resolve: { |
| 36 | + alias: { |
| 37 | + "@root": path.resolve(__dirname, "../src"), |
| 38 | + }, |
| 39 | + extensions: [".ts", ".tsx", ".js", ".json"] |
| 40 | + }, |
| 41 | + module: { |
| 42 | + rules: [ |
| 43 | + {enforce: "pre", test: /\.js$/, loader: "source-map-loader"}, |
| 44 | + { |
| 45 | + test: /\.tsx?$/, |
| 46 | + use: [ |
| 47 | + { |
| 48 | + loader: 'ts-loader', |
| 49 | + options: { |
| 50 | + transpileOnly: true |
| 51 | + } |
| 52 | + } |
| 53 | + ] |
| 54 | + } |
| 55 | + ] |
| 56 | + }, |
| 57 | + plugins: [ |
| 58 | + new ForkTsCheckerWebpackPlugin({ |
| 59 | + tsconfig: path.resolve(__dirname, "../tsconfig.json"), |
| 60 | + tslint: path.resolve(__dirname, "../tslint.json"), |
| 61 | + }), |
| 62 | + |
| 63 | + new HtmlWebpackPlugin({ |
| 64 | + template: "../src/app.html", |
| 65 | + filename: "index.html", |
| 66 | + }), |
| 67 | + new webpack.HotModuleReplacementPlugin(), |
| 68 | + |
| 69 | + // prints more readable module names in the browser console on HMR updates |
| 70 | + //new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), |
| 71 | + |
| 72 | + ], |
| 73 | +} |
0 commit comments