-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.dev.dist.js
117 lines (115 loc) · 3.85 KB
/
webpack.dev.dist.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
const webpackConstant = require('./webpack.constant');
const WebpackMerge = require('webpack-merge');
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
const DefinePlugin = webpack.DefinePlugin;
const NamedModulesPlugin = webpack.NamedModulesPlugin;
const WebpackCommon = require('./webpack.base');
module.exports = WebpackMerge(WebpackCommon, {
output: {
path: path.join(__dirname, webpackConstant.OutputDistPath),
publicPath: webpackConstant.ProdPublicPath
},
module: {
rules: [
{
test: /\.tsx?$/,
use: [
{
loader: "awesome-typescript-loader",
options: {
useBabel: false,
useCache: false, //使用babel时打开可减少编译时间
babelCore: undefined, //babel-core不在node_modules中时设置,undefined时默认在node_modules中查找babel-core
configFileName: path.join(__dirname, 'tsconfig.dev.json')
}
}
]
},
{
test: /\.html?$/,
use: [
{
loader: 'html-loader',
options: {
minimize: false
}
}
]
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader"
},
{
loader: 'postcss-loader'
}
]
})
},
{
test: /\.scss$/,
use: ExtractTextPlugin.extract({
fallback: "style-loader",
use: [
{
loader: "css-loader"
},
{
loader: "postcss-loader",
},
{
loader: "sass-loader"
}
]
})
}
]
},
plugins: [
new CleanWebpackPlugin(['dist/**', 'declaration/**'], {
root: __dirname,
verbose: true,
dry: false,
watch: true
}),
new CopyWebpackPlugin([
{
from: path.join(__dirname, webpackConstant.SrcPublicJsPath, 'webpack-dll'),
to: path.join(__dirname, webpackConstant.OutputDistPath, webpackConstant.OutputPublicJsPath, 'webpack-dll')
}
]),
new DefinePlugin({
'process.env': {
NODE_ENV: '"development"'
}
}),
new NamedModulesPlugin(),
new ExtractTextPlugin({
filename: path.join(webpackConstant.OutputPublicCssPath, '[name].[hash].css')
}),
// new UglifyJsPlugin({
// compress: {
// warnings: false,
// drop_console: true,
// screw_ie8: true,
// unsafe: true
// },
// beautify: true,
// mangle: {
// screw_ie8: true,
// keep_fnames: true
// },
// comments: false
// })
],
devtool: 'cheap-module-eval-source-map'
});