-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
94 lines (76 loc) · 2.64 KB
/
webpack.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const webpack = require("@nativescript/webpack");
const dotenv = require("dotenv");
const NativeScriptHTTPPlugin = require("@klippa/nativescript-http/webpack"); // Import NativeScriptHTTPPlugin
// const CopyWebpackPlugin = require('copy-webpack-plugin')
// const { relative, resolve, dirname } = require('path');
module.exports = (env) => {
dotenv.config({ path: process.env.ENV_PATH });
// env.appComponents = (env.appComponents || []).concat(['./app/fcmreceiver.android'])
webpack.init(env);
// Learn how to customize:
// https://docs.nativescript.org/webpack
//to fix new firebase issue
webpack.mergeWebpack({ resolve: {fallback:{fs:false,path:false}} })
webpack.Utils.addCopyRule('**/*.svg')
dotenv.config()
const isUppercase = key => key.toUpperCase() === key;
const envKeys = Object.keys(env);
let dotEnvValues = envKeys
.filter(isUppercase)
.reduce((memo, key) => {
return {...memo, [key]: JSON.stringify(env[key])};
}, {})
const dotEnvkeys = Object.keys(process.env);
dotEnvValues = dotEnvkeys
.filter(isUppercase)
.reduce((memo, key) => {
if (memo[key]) {
return memo;
}
return {...memo, [key]: dotEnvValues[key] || JSON.stringify(process.env[key])};
}, {...dotEnvValues})
// console.log(dotEnvValues);
webpack.chainWebpack(config => {
config.plugin('DefinePlugin').tap(args => {
Object.assign(args[0], dotEnvValues)
return args
})
})
// webpack.Utils.addCopyRule({
// from: '**/*.svg',
// noErrorOnMissing: true,
// // the context of the "from" rule, in this case node_modules
// // we used the getProjectFilePath util here, but this could have been
// // a path.resolve(__dirname, 'node_modules') too.
// context: webpack.Utils.project.getProjectFilePath('node_modules')
// })
webpack.chainWebpack(config => {
config.plugin('NativeScriptHTTPPlugin').use(NativeScriptHTTPPlugin)
// config.module
// .rule('scss')
// .use('sass-loader')
// .options({ sassOptions: { indentedSyntax: true } })
// config.module
// .rule('something')
// .test(/\.something$/)
// .use('something-loader')
// .loader('something-loader')
// .options({
// example: true
// })
})
// {
// test: /[\/|\\]app\.scss$/,
// use: [
// 'nativescript-dev-webpack/style-hot-loader',
// {
// loader: "nativescript-dev-webpack/css2json-loader",
// options: { useForImports: true }
// },
// 'sass-loader',
// + 'postcss-loader'
// ],
// }
webpack.mergeWebpack({ resolve: {conditionNames:['svelte','require','node'] }})
return webpack.resolveConfig();
};