forked from 2fps/recorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.dev.js
64 lines (58 loc) · 1.75 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
62
63
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
let config = {
// 入口
entry: path.join(__dirname, './example/index.tsx'),
devtool: 'source-map',
devServer: {
contentBase: './example'
},
output: {
filename: 'bundle.js',
path: path.join(__dirname, './demo')
},
module: {
// unknownContextCritical : false,
rules:[{
test: /\.css$/,
use: ['style-loader', 'css-loader']
}, {
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/
}, {
test: /\.(png|jpg|svg)$/,
loader: 'url-loader?limit=8192'
}, {
test: /\.(ttf|eot|woff|woff2)$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]',
},
}]
},
resolve: {
extensions: ['.js', '.tsx', '.ts', '.json'],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, 'example/example.html'),
filename: 'index.html',
inject: true
}),
new CleanWebpackPlugin()
]
};
module.exports = (env, argv) => {
if (argv.mode === 'development') {
// 移动端下增加 vconsole 调试
// config.entry.vconsole = path.resolve(__dirname, 'example/vconsole.ts');
// 开发模式下增加 example
// config.entry.example = path.resolve(__dirname, 'example/example.ts');
// config.entry.example = path.resolve(__dirname, 'example/index.tsx');
// 开发模式下才要用到html
}
return config;
}