|
1 | | -const path = require('path'); |
2 | | -const srcDir = path.resolve(__dirname, 'src'); |
3 | | -const distDir = path.resolve(__dirname, 'dist'); |
4 | | -const HtmlWebpackPlugin = require('html-webpack-plugin'); |
| 1 | +const HtmlWebpackPlugin = require("html-webpack-plugin"); |
| 2 | +const HOST = process.env.HOST || "localhost"; |
| 3 | +const PORT = process.env.PORT || "9000"; |
| 4 | +const path = require("path"); |
| 5 | +const srcDir = path.resolve(__dirname, "src"); |
| 6 | +const distDir = path.resolve(__dirname, "dist"); |
5 | 7 |
|
6 | 8 | module.exports = { |
7 | | - mode: 'development', |
8 | | - devtool: 'cheap-module-source-map', |
9 | | - entry: [ |
10 | | - path.join(srcDir, 'index.js') |
11 | | - ], |
| 9 | + mode: "development", |
| 10 | + devtool: "cheap-module-source-map", |
| 11 | + entry: [path.join(srcDir, "index.js")], |
12 | 12 | output: { |
13 | 13 | path: distDir, |
14 | | - filename: '[name].bundle.js' |
| 14 | + filename: "[name].bundle.js" |
15 | 15 | }, |
16 | 16 | devServer: { |
17 | | - contentBase: distDir, |
18 | | - historyApiFallback: true, |
| 17 | + host: HOST, |
| 18 | + port: PORT, |
19 | 19 | compress: true, |
20 | | - clientLogLevel: 'info', |
21 | | - host: 'localhost', |
22 | | - port: 9001 |
| 20 | + inline: true, |
| 21 | + historyApiFallback: true, |
| 22 | + hot: true, |
| 23 | + overlay: true, |
| 24 | + open: true |
23 | 25 | }, |
24 | 26 | module: { |
25 | 27 | rules: [ |
26 | 28 | { |
27 | 29 | test: /\.js?$/, |
28 | 30 | use: [ |
29 | 31 | { |
30 | | - loader: 'babel-loader' |
| 32 | + loader: "babel-loader" |
31 | 33 | } |
32 | 34 | ] |
| 35 | + }, |
| 36 | + { |
| 37 | + test: /\.css$/, |
| 38 | + use: ["style-loader", "css-loader"] |
| 39 | + }, |
| 40 | + { |
| 41 | + test: /\.(ttf|eot|woff|woff2)$/, |
| 42 | + use: { |
| 43 | + loader: "file-loader", |
| 44 | + options: { |
| 45 | + name: "fonts/[name].[ext]" |
| 46 | + } |
| 47 | + } |
33 | 48 | } |
34 | 49 | ] |
35 | 50 | }, |
36 | 51 | plugins: [ |
37 | 52 | new HtmlWebpackPlugin({ |
38 | | - template: path.join(srcDir, 'index.html') |
| 53 | + template: path.join(srcDir, "index.html") |
39 | 54 | }) |
40 | 55 | ] |
41 | | -} |
| 56 | +}; |
0 commit comments