-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
72 lines (67 loc) · 2.14 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
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var AutoPrefixer = require('autoprefixer');
var options = require('./project');
var pkg = require('./package.json');
var env = process.env.NODE_ENV
, jshash = '.[hash:10]'
, plugins = []
, loaders = [
{ test: /\.js$/, exclude: /node_modules/, loader: "babel" }
];
if ( env != 'production' ){
jshash = '';
plugins = [];
loaders.push(
{ test: /\.css$/, loader: "style!css!postcss" },
{ test: /\.less$/, loader: "style!css!postcss!less" },
{ test: /\.scss$/, loader: "style!css!postcss!sass" },
{ test: /\.(png|jpg)$/, loader: 'url-loader?limit=8192' },
{ test: /\.html$/, loader: "html" }
);
}
else{
loaders.push(
{ test: /\.css$/, loader: ExtractTextPlugin.extract("style", "css!postcss") },
{ test: /\.less$/, loader: ExtractTextPlugin.extract("style", "css!postcss!less") },
{ test: /\.scss$/, loader: ExtractTextPlugin.extract("style", "css!postcss!sass") },
{ test: /\.html$/, loader: "html!html-minify" }
);
if ( options.css ){
var ext = '.[contenthash:10].css';
if ( pkg['project-type'] === 'umd' ){
ext = '.css';
}
plugins.push(new ExtractTextPlugin(options.css + ext));
}
}
var result = {
entry: options.js.from[env],
output: {
path: options.output,
filename: options.js.to + (env == 'production' ? '' : jshash) + '.js'
},
module: {
loaders: loaders,
postLoaders: [
{ test: /vue-icons/, loader: "callback-loader"}
]
},
callbackLoader:require("vue-icons/icon-loader")([
"fa-thumbs-up",
"fa-angle-right",
"iconic-chevron-right",
"octicon-chevron-right"
]),
postcss: function(){
return [AutoPrefixer({ browsers: ['last 20 versions'] })]
},
plugins: plugins
};
if ( env != 'production' ){
result.output.library = pkg['project-library'];
result.output.libraryTarget = 'var';
}else{
result.output.library = pkg['project-library'];
result.output.libraryTarget = 'umd';
}
module.exports = result;