-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
83 lines (83 loc) · 2.1 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
let path = require('path');
let webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
let outputDir = 'docs';
module.exports = {
entry: {
index:'./src/index.ts',
//base:'./src/style/root.styl'
},
output: {
path: path.join(__dirname, outputDir), //输出目录的配置,模板、样式、脚本、图片等资源的路径配置都相对于它
filename: "bundle.js"
},
resolve: {
// 设置别名
alias: {
'@': path.resolve('src'),// 这样配置后 @ 可以指向 src 目录
'~pkg': path.resolve('src/packages')// 这样配置后 @ 可以指向 src 目录
}
},
module: {
rules: [
{
test: /\.ts$/,
loader: ['ts-loader'],
exclude: /node_modules/
},
{
test: /\.css$/,
loader: ['style-loader', 'css-loader']
},
{
test: /\.styl$/,
//loader: 'style-loader!css-loader!stylus-loader'
loader: 'css-loader!stylus-loader'
},
{
test: /\.styl$/,
include: path.join(__dirname,'src/style'),
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
//publicPath: 'style',
},
},
{
loader: "css-loader",
options: {
//importLoader: 1
}
},
'stylus-loader',
]
}
]
},
plugins:[
new MiniCssExtractPlugin({
filename: "style/base.css",
chunkFilename: "[name].chunk.css"
}),
new CopyWebpackPlugin([
{
from:__dirname+'/public',
to:__dirname+'/'+outputDir
}
])
],
devServer: {
headers: {
"X-Custom-Foo": "bar"
},
contentBase: path.join(__dirname, outputDir),
compress: true,
port: 9000
},
stats: {
modules: false,// 关闭编译时node_modules文件提示信息
entrypoints: false //关闭编译时插件entrypoint相关提示信息
}
};