-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
122 lines (116 loc) · 3.03 KB
/
webpack.config.js
File metadata and controls
122 lines (116 loc) · 3.03 KB
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
118
119
120
121
122
'use strict';
var path = require('path')
, webpack = require('webpack')
, ExtractTextPlugin = require('extract-text-webpack-plugin')
, ManifestPlugin = require('webpack-manifest-plugin')
, LicenseWebpackPlugin = require('license-webpack-plugin')
;
var nodeEnv = process.env.NODE_ENV || 'production';
console.log('» webpack:', nodeEnv);
var filename = '[name]';
if (nodeEnv === 'production') {
filename += '.[contenthash]';
}
var stylusBundler = new ExtractTextPlugin(filename + '.css')
, svgBundler = new ExtractTextPlugin('img/' + filename + '.svg')
;
var appName = 'willisau'
;
var config = {
output: {
path: path.resolve(__dirname, 'tmp/build/')
, filename: (nodeEnv === 'production' ?
'[name].[chunkhash].js' : '[name].js')
}
, module: {
loaders: [{
test: /\.css$/
, loader: stylusBundler.extract(['css'])
}, {
test: /\.styl$/
, loader: stylusBundler.extract(['css', 'stylus'])
, include: [
path.resolve(__dirname, appName + '/assets')
]
}, {
test: /\.js$/
, loader: 'babel-loader'
, include: [
path.resolve(__dirname, appName + '/assets')
]
}, { // open-iconic
test: /open-iconic\.min\.svg$/
, loader: svgBundler.extract(['svg-sprite'])
, include: [
path.resolve(__dirname,
'node_modules/open-iconic/sprite/open-iconic.min.svg')
]
}]
}
, resolve: {
extensions: ['', '.css', '.js', '.svg']
, alias: {
'styr\.css$': 'styr/dst/styr.min.css'
, 'fontfaceobserver\.js$': 'fontfaceobserver/fontfaceobserver.js'
, 'open-iconic\.svg$': 'open-iconic/sprite/open-iconic.min.svg'
}
}
, plugins: (function() {
var _plugins = [
stylusBundler
, svgBundler
];
_plugins.push(
new webpack.EnvironmentPlugin([
'NODE_ENV'
])
);
_plugins.push(
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(nodeEnv)
})
);
_plugins.push(
new webpack.ProvidePlugin({
'jQuery': 'jquery'
, 'window.d3': 'd3\.js'
, 'window.moment': 'moment\.js'
})
);
if (nodeEnv === 'production') {
_plugins.push(
new ManifestPlugin({
fileName: 'manifest.json'
})
);
_plugins.push(
new LicenseWebpackPlugin({
pattern: /^(MIT|ISC|BSD.*)$/
, filename: 'freesoftware-licenses.txt'
, addLicenseText: false
, licenseFilenames: [
// These filese are needed to check license in package.json.
'LICENSE', 'LICENSE.md', 'LICENSE.txt'
, 'license', 'license.md', 'license.txt'
, 'README', 'README.md', 'README.txt'
, 'readme', 'readme.md', 'readme.txt'
]
})
);
_plugins.push(
new webpack.optimize.UglifyJsPlugin({
debug: false
, minimize: true
, compress: {
warnings: false
}
, output: {
comments: false
}
})
);
}
return _plugins;
})()
};
module.exports = config;