-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
71 lines (66 loc) · 2.55 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
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
var path = require('path')
module.exports = {
devtool: 'eval-source-map',
entry: __dirname + "/index.js",
output: {
path: __dirname + "/build/",
filename: "bundle.js"
},
resolve: {
extensions: [' ', '.js', '.es6', '.vue'],
alias:{
jquery: './public/lib/jquery-vendor.js',
bootconfig:'./node_modules/bootstrap-webpack/bootstrap.config.js'
}
},
externals: {
'jquery': 'window.jQuery',
'photoUpload' : 'window.PhotoUpload'
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules|vendor|bootstrap/,
include: path.resolve(__dirname, 'public/js'),
loader: 'babel-loader',
query:{
presets:['es2015']
}
}, {
test: /\.css$/,
use:ExtractTextPlugin.extract({
fallback:'style-loader',
use:'css-loader'
}) //添加对样式表的处理
}, {
test: /\.less$/,
loader: 'style-loader!css-loader!less-loader',
}, {
test: /\.(png|jpg|gif)$/,
loader: 'url-loader?limit=8192&outputPath=img/' // <= 8kb的图片base64内联
}, {
// 专供iconfont方案使用的,后面会带一串时间戳,需要特别匹配到
test: /\.(woff|woff2|svg|eot|ttf)\??.*$/,
loader: 'file-loader?name=[name].[hash:7].[ext]&outputPath=fonts/',
}, {
test: require.resolve('jquery'), // 此loader配置项的目标是NPM中的jquery
loader: 'expose-loader?$!expose-loader?jQuery', // 先把jQuery对象声明成为全局变量`jQuery`,再通过管道进一步又声明成为全局变量`$`
}, {
test: /bootstrap\/js\//,
loader: 'imports?jQuery=jquery'
}]
},
plugins: [
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
'window.jQuery': 'jquery',
'window.$': 'jquery',
}),
new ExtractTextPlugin({
filename:"upload.min.css",
}),
],
}