-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathwebpack.dev.js
61 lines (59 loc) · 1.55 KB
/
webpack.dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
const path = require('path');
const webpack = require('webpack');
const { merge } = require('webpack-merge');
const common = require('./webpack.common.js');
const packageJson = require('./package');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
// const ReactRefreshPlugin = require('@pmmmwh/react-refresh-webpack-plugin');
const port = 3000;
const host = 'localhost';
module.exports = merge(common, {
mode: 'development',
devtool: 'source-map',
entry: { app: './src/app.tsx' },
devServer: {
static: {
directory: path.join(__dirname, 'build'),
},
host: host,
port: port,
hot: true,
},
output: {
path: path.resolve(__dirname, './build'),
filename: '[name].js',
publicPath: '/',
},
module: {
rules: [
{
test: /\.([jt])s(x)?$/,
exclude: /node_modules/,
include: path.join(__dirname, 'src'),
use: [
{
loader: 'ts-loader',
options: { transpileOnly: true },
},
].filter(Boolean),
},
{
test: /\.s[ac]ss$/i,
use: ['style-loader', 'css-loader', 'sass-loader'].filter(Boolean),
},
],
},
plugins: [
// new ReactRefreshPlugin(),
new ForkTsCheckerWebpackPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('development'),
}),
new HtmlWebpackPlugin({
inject: true,
filename: './index.html',
template: __dirname + '/src/index.html',
}),
],
});