-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
96 lines (89 loc) · 2.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
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const Visualizer = require('webpack-visualizer-plugin');
const devMode = process.env.NODE_ENV !== 'production';
module.exports = {
// Include source maps in development files
devtool: devMode ? '#cheap-module-source-map' : false,
context: path.join(__dirname, 'src'),
plugins: [
new MiniCssExtractPlugin({
filename: 'css/main.css',
chunkFilename: '[id].[hash]',
}),
new CopyWebpackPlugin([{
from: './assets/images',
to: 'images',
}, ]),
new HtmlWebpackPlugin({
title: 'Currency Converter PWA',
template: path.resolve(__dirname, 'src/views/index.ejs'),
excludeChunks: [ 'sw.js', ],
}),
new Visualizer(),
],
entry: {
'js/main': [
'babel-polyfill',
'../node_modules/indexeddbshim/dist/indexeddbshim.min.js', // IDB PolyFill
'./main.js',
],
sw: './sw.js',
},
resolve: {
extensions: ['*', '.js', ],
modules: [
path.resolve(__dirname, 'node_modules'),
],
alias: {
handlebars: 'handlebars/dist/handlebars.min.js',
},
},
output: {
filename: '[name].js',
chunkFilename: '[id].[hash]',
path: path.resolve(__dirname, 'dist'),
globalObject: 'this', // https://github.com/webpack/webpack/issues/6642#issuecomment-371087342
},
module: {
rules: [{
test: /\.js$/,
exclude: /node_modules/,
use: [
'babel-loader',
],
},
{
test: /\.(woff2?|eot|ttf|otf)(\?.*)?$/,
loader: 'url-loader',
options: {
limit: 1000,
name: 'fonts/[name].[ext]',
publicPath: '../', // 😄 https://github.com/webpack-contrib/file-loader/issues/32#issuecomment-250622904
},
},
{
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: 'images/[name].[ext]',
},
},
{
test: /\.(sa|sc|c)ss$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
'sass-loader',
],
},
{
test: /\.hbs$/,
loader: 'text-loader',
},
],
},
};