forked from RocketChat/Rocket.Chat.Livechat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpreact.config.js
27 lines (26 loc) · 891 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
/**
* Function that mutates original webpack config.
* Supports asynchronous changes when promise is returned.
*
* @param {object} config - original webpack config.
* @param {object} env - options passed to CLI.
* @param {WebpackConfigHelpers} helpers - object with useful helpers when working with config.
**/
export default (config, env, helpers) => {
// Use Preact CLI's helpers object to get the babel-loader
const babel = helpers.getLoadersByName(config, 'babel-loader')[0].rule;
// Update the loader config to include preact-i18nline
babel.loader = [
{ // create an entry for the old loader
loader: babel.loader,
options: babel.options,
},
{ // add the preact-i18nline webpack loader
loader: 'preact-i18nline/webpack-loader',
},
];
// remove the old loader options
delete babel.options;
config.resolve.alias.styles = './src/styles';
return config;
};