-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
executable file
·144 lines (120 loc) · 3.64 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
/* global __dirname, process */
const path = require('path');
const webpack = require('webpack');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const SoundNotificationPlugin = require('sound-notification-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const isProd = process.argv.indexOf('--prod') !== -1;
const outputPath = path.resolve(__dirname, './dist');
const srcDir = path.resolve(__dirname, './src');
const servePath = path.resolve(__dirname, './.tmp');
var webpackConfig = {
debug: true,
entry: {
app: path.join(srcDir, 'index.js')
},
devtool: 'eval', //sourcemap, eval ...
output: {
path: outputPath,
filename: '[name].js'
},
module: {
noParse: '/node_modules/',
loaders: [
// Src JS
{
test: /\.js$/,
loaders: ['ng-annotate', 'babel?cacheDirectory'],
include: [srcDir]
},
//CSS
{
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader')
},
// LESS
{
test: /\.less$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader!less-loader')
},
// HTML
{
test: /\.html$/,
exclude: /index\.html/,
loader: 'html'
},
// Fonts
{
test: /\.(woff|woff2|svg|ttf|eot)([\?]?.*)$/,
loader: 'file-loader?name=fonts/[name].[ext]'
},
// Static Imgs
{
test: /\.jpe?g$|\.gif$|\.png$|\.ico$/,
loader: 'file-loader?name=imgs/[name].[ext]'
},
// json
{
test: /\.json$/,
loader: 'json-loader'
}
]
},
resolve: {
modulesDirectories: ['node_modules', 'bower_components'],
alias: {
'npm': path.resolve(__dirname, 'node_modules'),
'bower': path.resolve(__dirname, 'bower_components')
}
},
plugins: [
//Remove duplicates
new webpack.optimize.DedupePlugin(),
// Separete vendors to a vendors.js file
new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
filename: 'vendor.js',
minChunks: function (module) {
return module.resource && module.resource.indexOf(srcDir) === -1;
}
}),
// Creates index.html
new HtmlWebpackPlugin({
title: 'Pedro&Bino',
pkg: require('./package.json'),
template: path.join(srcDir, 'index.html'),
inject: true,
minify: { collapseWhitespace: isProd }
}),
// Extracts css to a contained file
new ExtractTextPlugin('app.css'),
// Sound notification
new SoundNotificationPlugin()
],
devServer: {
contentBase: servePath,
noInfo: false, // --no-info option
hot: false
}
};
if (isProd) {
webpackConfig.devtool = 'sourcemap';
webpackConfig.debug = false;
webpackConfig.plugins.push(new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
compress: {
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true,
},
output: {
comments: false
}
}));
}
module.exports = webpackConfig;