|
1 | 1 | const HtmlWebpackPlugin = require("html-webpack-plugin");
|
2 | 2 | const path = require('path');
|
3 | 3 |
|
4 |
| -module.exports = { |
5 |
| - entry: './src/index.ts', |
6 |
| - module: { |
7 |
| - rules: [ |
8 |
| - { |
9 |
| - test: /\.ts?$/, |
10 |
| - use: 'ts-loader', |
11 |
| - exclude: /node_modules/, |
12 |
| - } |
13 |
| - ], |
14 |
| - }, |
15 |
| - resolve: { |
16 |
| - extensions: ['.tsx', '.ts', '.js'], |
17 |
| - }, |
18 |
| - output: { |
19 |
| - filename: 'bundle.js', |
20 |
| - path: path.resolve(__dirname, 'dist'), |
21 |
| - }, |
| 4 | +module.exports = (env: any) => { |
| 5 | + // https://webpack.js.org/guides/environment-variables/ Use env.<YOUR VARIABLE> here: |
| 6 | + console.log('KEYPOST_APP_HOST: ', env.KEYPOST_APP_HOST); |
| 7 | + console.log('production: ', env.production || false); |
| 8 | + |
| 9 | + return { |
| 10 | + entry: './src/index.ts', |
| 11 | + module: { |
| 12 | + rules: [ |
| 13 | + { |
| 14 | + test: /\.ts?$/, |
| 15 | + use: 'ts-loader', |
| 16 | + exclude: /node_modules/, |
| 17 | + } |
| 18 | + ], |
| 19 | + }, |
| 20 | + resolve: { |
| 21 | + extensions: ['.tsx', '.ts', '.js'], |
| 22 | + }, |
| 23 | + output: { |
| 24 | + filename: 'bundle.js', |
| 25 | + path: path.resolve(__dirname, 'dist'), |
| 26 | + }, |
22 | 27 |
|
23 |
| - plugins: [ |
24 |
| - // https://github.com/jantimon/html-webpack-plugin#options |
25 |
| - new HtmlWebpackPlugin({ |
26 |
| - title: 'tutorial', |
27 |
| - template: 'src/custom.html', |
28 |
| - filename: 'custom.html'}), |
29 |
| - new HtmlWebpackPlugin({ |
30 |
| - title: 'Keypost Home', |
31 |
| - template: 'src/index.html', |
32 |
| - filename: 'index.html'}) |
33 |
| - ], |
| 28 | + plugins: [ |
| 29 | + // https://github.com/jantimon/html-webpack-plugin#options |
| 30 | + new HtmlWebpackPlugin({ |
| 31 | + title: 'tutorial', |
| 32 | + template: 'src/custom.html', |
| 33 | + filename: 'custom.html'}), |
| 34 | + new HtmlWebpackPlugin({ |
| 35 | + title: 'Keypost Home', |
| 36 | + template: 'src/index.html', |
| 37 | + filename: 'index.html'}) |
| 38 | + ], |
34 | 39 |
|
35 |
| - devServer: { |
36 |
| - static: path.join(__dirname, "dist"), |
37 |
| - compress: true, |
38 |
| - port: 4000, |
39 |
| - }, |
| 40 | + devServer: { |
| 41 | + static: path.join(__dirname, "dist"), |
| 42 | + compress: true, |
| 43 | + port: 4000, |
| 44 | + }, |
| 45 | + }; |
40 | 46 | };
|
0 commit comments