-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathpreact.config.js
33 lines (27 loc) · 892 Bytes
/
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
import path from 'path';
import asyncPlugin from 'preact-cli-plugin-async';
import netlifyPlugin from 'preact-cli-plugin-netlify';
import WebpackCritical from 'webpack-critical';
export default (config, env, helpers) => {
asyncPlugin(config);
if (env.production) {
netlifyPlugin(config);
// Inline Critical CSS
config.plugins.push(
new WebpackCritical({
context: env.dest
})
);
}
helpers.getPluginsByName(config, 'DefinePlugin')[0].plugin.definitions.PRERENDER = String(env.ssr===true);
// @lib/foo is convenient
config.resolve.alias['@lib'] = path.resolve(__dirname, 'src/lib');
// Exempt the homepage from lazy-loading
helpers.getLoaders(config).forEach( ({ loaders, rule }) => {
if (loaders && String(loaders).match(/async-component-loader/)) {
rule.exclude = [
/\/routes\/home(\/index\.[a-z]+|\.js)$/gi
].concat(rule.exclude || []);
}
});
};