forked from ArturoLAnderson/beacon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
85 lines (76 loc) · 2.11 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
module.exports = {
entry: ['babel-polyfill', './app/index.js'],
output: {
path: path.join(__dirname, 'www'),
filename: '[name].[hash].js'
},
// production 模式下不生成 source map
// devtool: process.env['NODE_ENV'] === 'production' ? false : 'source-map',
externals: {
'better-sqlite3': 'commonjs better-sqlite3',
'nano-time': "require('nano-time')",
child_process: "require('child_process')",
process: "require('process')",
fs: "require('fs')",
os: "require('os')",
path: "require('path')",
crypto: "require('crypto')",
// Buffer: "require('Buffer')",
// buffer: "require('buffer')",
electron: "require('electron')"
},
module: {
rules: [
{
test: /\.js$/,
use: {
loader: 'babel-loader'
}
},
{
test: /.(png|woff|woff2|eot|ttf|svg)$/,
loader: 'url-loader?limit=100000'
},
{
test: /\.css$/,
use: [MiniCssExtractPlugin.loader, 'css-loader']
}
]
},
resolve: {
extensions: ['.js'],
plugins: []
},
plugins: [
new HtmlWebpackPlugin({ template: './app/index.html' }),
new CleanWebpackPlugin(
['www/main.*.js', 'www/main.*.css'], //匹配删除的文件
{
root: __dirname, //根目录
verbose: true, //开启在控制台输出信息
dry: false //启用删除文件
}
),
new webpack.ProvidePlugin({
$: 'jquery'
}),
new MiniCssExtractPlugin({
filename: '[name].[chunkhash:8].css',
chunkFilename: '[id].css'
})
// new webpack.HotModuleReplacementPlugin()
],
devServer: {
contentBase: [path.join(__dirname, 'www')], //静态文件根目录
watchContentBase: true,
port: 2018, // 端口
host: 'localhost',
overlay: true,
compress: true // 服务器返回浏览器的时候是否启动gzip压缩
}
};