-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
98 lines (86 loc) · 2.54 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
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
var notifier = require('node-notifier');
var path = require('path');
function rel (dir) {
return path.join(__dirname, dir);
}
module.exports = {
entry: './public/index.js',
output: {
path: path.resolve(__dirname, 'build'),
filename: 'app.bundle.js'
},
devtool: 'cheap-module-source-map',
module: {
loaders: [
{
test: /\.js$/i,
loaders: ['babel'],
include: [
rel('src')
]
},
// Import SASS stylesheets
{
test: /\.scss$/i,
loader: ExtractTextPlugin.extract('style', [
'css?sourceMap&importLoaders=1',
'postcss',
'resolve-url?sourceMap&keepQuery=false',
'sass?sourceMap'
])
},
// Optimise images referenced from CSS
// Files under 5kb will be inlined as data: URIs
{
test: /\.(?:jpe?g|png|gif|svg)(?:\?.+)?$/i,
loaders: [
'url?limit=5000&name=[name].[ext]'
]
},
// Allow inlining of HTML templates
{
test: /\.html$/i,
loader: 'ngtemplate?requireAngular&relativeTo=' + rel('public') + '/!html'
},
{
test: /\.js$/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
},
plugins: [
new ExtractTextPlugin('app.bundle.css'),
new FriendlyErrorsWebpackPlugin({
onErrors: function (severity, errors) {
if (severity !== 'error') {
return;
}
var error = errors[0];
notifier.notify({
title: 'Dev Build',
message: severity + ': ' + error.name,
subtitle: error.file || ''
});
}
}),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.NoErrorsPlugin()
],
resolve: {
extensions: ['', '.js', '.scss']
},
stats: {
colors: true
},
postcss: function () {
return [
require('autoprefixer')
];
}
};