-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmetacraft.config.js
59 lines (50 loc) · 1.23 KB
/
metacraft.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
48
49
50
51
52
53
54
55
56
57
58
59
const { resolve } = require('path');
const CopyPlugin = require('copy-webpack-plugin');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const setEnvironments = (configs, internal) => {
const { webpack } = internal.modules;
const { DefinePlugin } = webpack;
const env = internal.configs.env();
const isProduction = internal.configs.isProduction(env);
configs.plugins[0] = new DefinePlugin({
process: { env: {} },
__DEV__: !isProduction,
ENV: JSON.stringify(env),
});
return configs;
};
const copyAssets = (configs) => {
configs.plugins.push(
new CopyPlugin({
patterns: [
{
from: resolve(process.cwd(), 'assets/'),
to: './',
filter: (uri) => {
const isFont = uri.indexOf('/fonts/') >= 0;
const isTemplate = uri.endsWith('.ejs') || uri.endsWith('.sass');
return !isFont && !isTemplate;
},
},
],
}),
);
return configs;
};
const customLoaders = (configs) => {
configs.module.rules.push({
test: /\.md$/i,
type: 'asset/source',
});
return configs;
};
module.exports = {
useBabel: true,
buildId: () => 'app',
webpackMiddlewares: [setEnvironments, copyAssets, customLoaders],
moduleAlias: {
global: {
'react-native': 'react-native-web',
},
},
};