-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreact.config.js
36 lines (33 loc) · 1.28 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
import Dotenv from 'dotenv-webpack'
const crypto = require("crypto");
// const Visualizer = require('webpack-visualizer-plugin');
/**
* md4 algorithm is not available anymore in NodeJS 17+ (because of lib SSL 3).
* In that case, silently replace md4 by md5 algorithm.
*
* FIXME: This is like super hacky, and once `preact-cli` is on WebPack 5, this
* should be removed. It might be a security risk? But I'm not incredibly
* concerned since none of this should be used at runtime.
*/
try {
crypto.createHash('md4');
} catch (e) {
console.warn('Crypto "md4" is not supported anymore by this Node version');
const origCreateHash = crypto.createHash;
crypto.createHash = (alg, opts) => {
return origCreateHash(alg === 'md4' ? 'md5' : alg, opts);
};
}
/**
* @param {import('preact-cli').Config} config - Original webpack config
* @param {import('preact-cli').Env} env - Current environment info
* @param {import('preact-cli').Helpers} helpers - Object with useful helpers for working with the webpack config
*/
export default (config, env, helpers) => {
config.plugins.push(new Dotenv({path: "./.env", systemvars: true}));
// config.plugins.push(new Visualizer());
if (env.isProd) {
config.devtool = false;
config.mode = "production";
}
}