-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
70 lines (69 loc) · 2.01 KB
/
webpack.config.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
62
63
64
65
66
67
68
69
70
/*
* Created by charlotte.wang([email protected]) on 2019/01/25
* Last Modified by charlotte.wang on 2019/01/29
* Copyright (c) 2019 Gago Ltd.
*
* HISTORY:
* Date By Comments
* ---------- --------- -------------------------------------------------------
*/
const path = require('path');
const webpack = require('webpack');
var ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HappyPack = require('happypack');
const chalk = require('chalk');
console.log(chalk.blue('haha'));
module.exports = {
name: 'app',
mode: process.env.NODE_ENV,
entry: {
app: ['./src/app/app.tsx'],
vendor: ['@babel/polyfill', 'react', 'react-dom'],
},
// entry: ["webpack-hot-middleware/client", 'webpack/hot/only-dev-server', "./src/app/app.tsx"],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].bundle.js',
},
devtool: 'source-map',
resolve: {
extensions: ['.js', '.jsx', '.json', '.ts', '.tsx'],
alias: {
// "react-hot-loader": path.resolve(path.join(__dirname, "./node_modules/react-hot-loader")),
react: path.resolve(path.join(__dirname, './node_modules/react')),
},
},
module: {
rules: [
{
test: /\.(ts|tsx)$/,
loader: 'babel-loader',
options: {
cacheDirectory: true,
},
// include: [path.resolve("src")],
exclude: /node_modules/,
},
{
test: /\.js$/,
use: 'happypack/loader?id=js-pack',
// loader: "babel-loader?cacheDirectory=true",
include: [path.resolve('src')],
exclude: /node_modules/,
},
{ enforce: 'pre', test: /\.js$/, loader: 'source-map-loader' },
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'src/app', 'index.html'),
}),
new ForkTsCheckerWebpackPlugin(),
new HappyPack({
id: 'js-pack',
threads: 4,
loaders: ['babel-loader?cacheDirectory=true'],
}),
],
};