-
Notifications
You must be signed in to change notification settings - Fork 35
/
webpack.prod.config.js
43 lines (34 loc) · 1.14 KB
/
webpack.prod.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
'use strict';
const glob = require('glob');
const OfflinePlugin = require('offline-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
const samples = require('./src/samples.json');
const makeConfig = require('./webpack.config');
const config = makeConfig({ lastStyleLoader: MiniCssExtractPlugin.loader });
const sampleFilenames = ['ogg', 'mp3'].reduce(
(filenames, format) =>
filenames.concat(Object.values(samples[`vsco2-piano-reverb-${format}`])),
[]
);
const iconFilenames = glob.sync('icons/**/*.png');
const otherFilenames = [
'favicon.ico',
'manifest.json',
'https://fonts.googleapis.com/css?family=Merriweather:300i',
];
const filenamesToCache = sampleFilenames
.concat(iconFilenames)
.concat(otherFilenames);
config.plugins.push(
new CleanWebpackPlugin(['dist']),
new MiniCssExtractPlugin({ filename: '[name].[hash].css' }),
new OfflinePlugin({
appShell: '/',
externals: filenamesToCache,
autoUpdate: true,
})
);
config.mode = 'production';
delete config.devtool;
module.exports = config;