-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathwebpack.config.example.js
82 lines (81 loc) · 2.01 KB
/
webpack.config.example.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
var path = require('path')
var webpack = require('webpack')
var HtmlWebpackPlugin = require('html-webpack-plugin');
var port = 3010
module.exports = {
context: path.resolve(__dirname, 'example'), // string(绝对路径!)
devtool: 'eval',
cache: true,
entry: [
'./main.js'
],
output: {
path: path.join(__dirname, 'demo/'),
filename: '[name].js', //.[hash]
// publicPath: 'http://public.dainli.com/17zt/viewer/assets/'
},
plugins: [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify("development")
}
}),
new webpack.NamedModulesPlugin(),
// 当模块热替换(HMR)时在浏览器控制台输出对用户更友好的模块名字信息
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
compress: {
warnings: true,
}
}),
new HtmlWebpackPlugin({
title: 'Custom template',
template: '../example/index.html', // Load a custom template (ejs by default see the FAQ for details)
hash: true,
filename:"./index.html"
})
],
resolve: {
modules: [
"node_modules",
path.resolve(__dirname, "src")
],
extensions: ['.js', '.jsx']
},
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader' ,
exclude: /node_modules/,
include: __dirname,
options: {
presets: [["es2015", {"modules": false}], "stage-1", "react"]
}
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
{ loader: 'postcss-loader', options: { config: { path: './postcss.config.js' } } }
]
},
{
test: /\.less/,
use: [
'style-loader',
'css-loader',
{ loader: 'postcss-loader', options: { config: { path: './postcss.config.js' } } },
'less-loader'
]
},
{
test: /\.(gif|jpg|png|woff|svg|eot|ttf)$/,
use: [
{ loader: 'file-loader'}
]
}
]
},
}