This repository has been archived by the owner on Sep 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
129 lines (117 loc) · 3.81 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
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
123
124
125
126
127
128
129
var webpack = require('webpack');
var path = require('path');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var pwd = __dirname;
var regexPathSep = process.platform === 'win32' ? '\\\\' : '\/';
var PRODUCTION = process.env.PRODUCTION;
var config = {};
/**************** INPUT ***************/
config.entry = {
app: 'signali',
admin: 'admin',
admin_vendor: 'admin/vendor',
head: [
'.modernizrrc'
]
};
/**************** OUTPUT ***************/
config.output = {
path: path.normalize(pwd + '/build'),
filename: '[name].js',
publicPath: '/static/'
};
/**************** PLUGINS ***************/
config.plugins = [];
if (PRODUCTION) {
config.plugins.push(new ExtractTextPlugin('[name].css'));
config.plugins.push(new webpack.optimize.DedupePlugin());
config.plugins.push(new webpack.optimize.OccurrenceOrderPlugin(true));
config.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
output: {comments: false}
}));
}
/**************** RESOLVING NAMES ***************/
config.resolve = {
root: [
path.normalize(pwd + '/elements/signali'),
path.normalize(pwd + '/elements')
],
alias: {
'jquery': 'jquery/dist/jquery'
},
// you can now require('file') instead of require('file.js')
extensions: ['', '.js', '.json']
};
config.externals = {
modernizr: 'var Modernizr'
};
/**************** DEV TOOLS ***************/
if (!PRODUCTION) {
config.devtool = "eval-source-map";
}
/**************** MODULE LOADING ***************/
var svgExtraLoaders = '';
if (PRODUCTION) {
svgExtraLoaders = '!svgo';
}
var skipProcessingLoader = 'imports?this=>window&module=>false&exports=>false&define=>false';
var getStylingLoader = function(additionalLoaders) {
var cssOptions = PRODUCTION ? {discardComments: {removeAll: true}} : {sourceMap: true, minimize: false};
var loaders = ['style', 'css?' + JSON.stringify(cssOptions), 'postcss'];
if (additionalLoaders) loaders.push(additionalLoaders);
if (!PRODUCTION) return loaders.join('!');
return ExtractTextPlugin.extract(loaders[0], loaders.splice(1).join('!'))
};
config.module = {
preLoaders:[
{test: /\.js$/, loader: 'eslint', exclude: /node_modules/}
],
loaders: [
{
test: /block-ui|tooltipster/,
loader: skipProcessingLoader
},
{
test: /\.modernizrrc$/,
loader: 'modernizr'
},
{
test: /\.scss$/,
loader: getStylingLoader('!sass?sourceMap')
},
{test: /\.css$/, loader: getStylingLoader()},
{test: new RegExp('autorequire'+regexPathSep+'.+$'), loader: 'file?name=auto/[name].[ext]'},
{test: /^(?:(?!autorequire).)+\.gif$/, loader: 'url?limit=100000&mimetype=image/gif'},
{test: /^(?:(?!autorequire).)+\.png$/, loader: 'url?limit=100000&mimetype=image/png'},
{test: /^(?:(?!autorequire).)+\.jpg$/, loader: 'file'},
{test: /\.html$/, loader: 'mustache'},
{test: /\.svg$/, loader: 'raw'+svgExtraLoaders},
{
test: new RegExp('(:?elements'+regexPathSep+'|node_modules'+regexPathSep+'skate).+\.js$'),
loader: 'babel',
query: {
cacheDirectory: true,
plugins: ['transform-class-properties'],
presets: ['es2015']
}
}
]
};
/**************** POSTCSS module ***************/
config.postcss = [autoprefixer({ browsers: [
'Android 2.3',
'Android >= 4',
'Chrome >= 35',
'Firefox >= 31',
'Explorer >= 9',
'iOS >= 7',
'Opera >= 12',
'Safari >= 7.1'
]})];
/**************** File changes watching/monitoring options ***************/
config.watchOptions = {
aggregateTimeout: 100
};
module.exports = config;