-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
105 lines (89 loc) · 2.33 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
const path = require('path');
const webpack = require('webpack');
// -- external webpack plugins
const CopyWebpackPlugin = require('copy-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
//const CompressionPlugin = require('compression-webpack-plugin');
// -- internal webpack plugins
const DefinePlugin = webpack.DefinePlugin;
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
const AggressiveMergingPlugin = webpack.optimize.AggressiveMergingPlugin;
const ContextReplacementPlugin = webpack.ContextReplacementPlugin;
module.exports = {
// define the tool used
// on development to aid debugging
devtool: 'source-map',
// entry point
entry: {
dmovies: 'bootstrap.js',
},
// output definition
output: {
filename: '[name].[hash].js',
path: path.join(__dirname, 'dist')
},
// plugins
plugins: [
new CopyWebpackPlugin([
{ from: 'src/favicon.ico' },
// { from: 'assets/favicon.ico' },
]),
new HtmlWebpackPlugin({
template: 'src/index.html',
}),
/*
new UglifyJsPlugin({
sourceMap: true,
mangle: { keep_fnames: true }
}),
new AggressiveMergingPlugin(),
new CompressionPlugin({
asset: "[path].gz[query]",
algorithm: "gzip",
test: /\.(js|css|html)$/,
threshold: 10240, // compress assets > 10KB
minRatio: 0.8 // with 80% compression ratio
})
*/
],
// loaders definitions
module: {
rules: [
// transpiles ES6
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
},
// process SASS/SCSS files and loads them
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader'],
exclude: /node_modules/,
},
// loads HTML templates
{
test: /\.html$/,
loader: 'html-loader',
exclude: /node_modules/,
},
// loads images
{
test: /\.(png|jpe?g)$/,
loader: 'file-loader',
exclude: /node_modules/,
},
// loads external fonts
{
test: /\.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,
loader: 'file-loader?name=fonts/[name].[ext]',
exclude: /node_modules/,
}
]
},
// resolvers definitions
resolve: {
extensions: ['.js'],
modules: [path.join(__dirname, 'src'), 'node_modules']
}
}