-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwebpack.common.config.js
91 lines (90 loc) · 2.86 KB
/
webpack.common.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
86
87
88
89
90
91
/**
* 通用打包配置
*/
'use strict';
const path = require('path'),
webpack = require('webpack'),
ExtractTextPlugin = require("extract-text-webpack-plugin");
const plugins = [];
module.exports = {
context: path.join(__dirname),
resolve: {
alias: {
'utils': path.join(__dirname, '../utils/'),
'assets': path.join(__dirname, '../assets/'),
'views': path.join(__dirname, '../views/'),
},
extensions: ['.js', '.vue'],
},
externals: {
vue: 'Vue'
},
resolveLoader: {
moduleExtensions: ["-loader"]
},
module: {
rules: [
{
test: /\.css$/,
// loader: ExtractTextPlugin.extract("css")
use: ExtractTextPlugin.extract({fallback:'style', use:'css?minimize!postcss'}),
},
{
test: /\.s[a|c]ss$/,
// loader: ExtractTextPlugin.extract("css!sass")
use: ExtractTextPlugin.extract({fallback:'style', use:'css?minimize!postcss!sass'}),
},
{
test: /\.vue$/,
loader: "vue",
options: {
postcss: require('./postcss.config.js'),
loaders: {
css: ExtractTextPlugin.extract({fallback:'vue-style', use:'css?minimize'}),
sass: ExtractTextPlugin.extract({fallback:'vue-style', use: 'css?minimize!sass'}),
scss: ExtractTextPlugin.extract({fallback:'vue-style', use: 'css?minimize!sass'}),
less: ExtractTextPlugin.extract({fallback:'vue-style', use: 'css?minimize!less'}),
jade: 'jade'
},
}
},
{
test: /\.jade/,
loader: "jade"
},
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel',
// query: {
// presets: ['es2015', 'stage-0'],
// plugins: ['transform-runtime']
// }
},
{
test: /\.(eot|woff|ico|ttf|svg)$/,
loader: "url?limit=8192&name=iconfont/[name].[ext]"
},
{
test: /\.(png|gif|ico|jpg)$/,
exclude: /\.dp\.(png|gif|ico|jpg)/,
loader: 'url?limit=8192&name=img/[hash:8].[ext]'
},
{
test: /\.dp\.(png|gif|ico|jpg)$/,
loader: "file?name=img/[hash:8].[ext]"
}
]
},
// babel: {
// presets: ['es2015', 'stage-0'],
// plugins: ['transform-runtime']
// },
stats: {
colors: true,
modules: true,
reasons: true
},
devtool: "source-map",
plugins: plugins,
};