-
Notifications
You must be signed in to change notification settings - Fork 9
/
preact.config.js
47 lines (42 loc) · 1.07 KB
/
preact.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
import preactCliSwPrecachePlugin from 'preact-cli-sw-precache';
import CopyWebpackPlugin from 'copy-webpack-plugin';
import netlifyPlugin from 'preact-cli-plugin-netlify';
export default (config, env, helpers) => {
config.output.publicPath = env.production ? '/' : '/';
config.plugins.push(
new helpers.webpack.DefinePlugin({
'process.env.PUBLIC_PATH': JSON.stringify(config.output.publicPath || '/')
}),
new CopyWebpackPlugin([
{ from: `${__dirname}/src/robots.txt` },
])
);
const precacheConfig = {
filename: 'sw.js',
navigateFallback: 'index.html',
navigateFallbackWhitelist: [/^(?!\/__).*/],
minify: true,
stripPrefix: config.cwd,
staticFileGlobsIgnorePatterns: [
/polyfills(\..*)?\.js$/,
/\.map$/,
/push-manifest\.json$/,
/.DS_Store/,
/\.git/
],
runtimeCaching: [
{
urlPattern: /^https:\/\/res\.cloudinary\.com\//,
handler: 'cacheFirst',
options: {
cache: {
maxEntries: 200,
name: 'items-cache'
}
}
}
]
};
netlifyPlugin(config);
return preactCliSwPrecachePlugin(config, precacheConfig);
};