-
Notifications
You must be signed in to change notification settings - Fork 1
/
webpack.config.js
executable file
·118 lines (113 loc) · 2.96 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
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const OfflinePlugin = require('offline-plugin');
const config = {
context: __dirname + '/app',
entry: {
main: './js/main.js'
},
output: {
path: __dirname + '/dist',
filename: 'bundle.js'
},
devServer: {
compress: true,
open: true,
contentBase: __dirname + '/app'
},
module: {
loaders: [
{
test: /\.js$/, //Check for all JS files
exclude: /node_modules/,
use: [{
loader: 'babel-loader',
options: { presets: ['es2015'] }
}]
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
loader: 'css-loader?importLoaders=1',
}),
},
{
test: /.*\.(gif|png|jpe?g|svg)$/i,
loaders: [
'file-loader',
{
loader: 'image-webpack',
query: {
progressive: true,
optimizationLevel: 7,
interlaced: false,
pngquant: {
quality: '65-90',
speed: 4
}
}
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
'NODE_ENV': process.env.NODE_ENV
}),
new ExtractTextPlugin({
filename: 'bundle.css',
allChunks: true,
}),
new HtmlWebpackPlugin({
template: __dirname + '/app/index.html',
filename: __dirname + '/dist/index.html',
minify: { collapseWhitespace: true }
})
],
devtool: 'eval-source-map'
}
// Setting plugins for production
if (process.env.NODE_ENV === "production") {
config.devtool = "";
config.plugins.push(
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
}
})
);
config.plugins.push(
new OfflinePlugin({
relativePaths: false,
AppCache: false,
publicPath: '/',
excludes: ['*.txt', '*.svg', 'CNAME', '**/.DS_Store', 'images/*.*', 'images/touch/*.*', 'images/touch/*.*', '**/*.map'],
externals: ['https://fonts.googleapis.com/css?family=Material+Icons', 'images/touch/favicon.ico', 'images/touch/apple-touch-icon-180x180.png', 'images/touch/apple-touch-icon-144x144.png']
})
);
config.plugins.push(
new CopyWebpackPlugin([
{
from: {
glob: __dirname + '/app/images/**/*',
dot: true
},
to: __dirname + '/dist'
},
{ from: __dirname + '/app/decoder.min.js', to: __dirname + '/dist/' },
{ from: __dirname + '/app/manifest.json', to: __dirname + '/dist/' },
{ from: __dirname + '/CNAME', to: __dirname + '/dist/' },
{ from: __dirname + '/robots.txt', to: __dirname + '/dist/' }
])
);
config.plugins.push(
new webpack.LoaderOptionsPlugin({
minimize: true,
debug: true
})
);
}
module.exports = config;