This repository was archived by the owner on Apr 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
75 lines (69 loc) · 2.03 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
const webpack = require("@nativescript/webpack");
const { getPlatformName } = require("@nativescript/webpack/dist/helpers/platform");
// const fakeEnv = {
// "hmr": true,
// "externals": [
// "~/package.json",
// "package.json"
// ],
// "android": true,
// "appPath": "app",
// "appResourcesPath": "App_Resources",
// "nativescriptLibPath": "C:\\Users\\foxpro\\AppData\\Roaming\\npm\\node_modules\\nativescript\\lib\\nativescript-cli-lib.js",
// "config": false,
// "sourceMap": true,
// "watch": true
// }
// webpack.init(fakeEnv);
// webpack.useConfig('base')
// const config = solid(webpack.resolveChainableConfig(), fakeEnv)
// //
module.exports = (env) => {
webpack.init(env);
webpack.useConfig("typescript");
const config = solid(webpack.resolveChainableConfig(), env);
return config.toConfig();
};
/**
*
* @param {import('webpack-chain')} config
* @param {*} env
* @returns
*/
function solid(config, env) {
const platform = getPlatformName();
const mode = env.production ? "production" : "development";
const production = mode === "production";
config.resolve.extensions.prepend(".tsx").prepend(`.${platform}.tsx`);
config.module.rules.delete("ts").end();
config.module
.rule("bundle-source")
.test(/\.(t|j)sx?$/)
.exclude.add(/node_modules/)
.end()
.use("babel-loader")
.loader("babel-loader")
.options({
babelrc: false,
configFile: false,
presets: [
[
"babel-preset-solid",
{
moduleName: "./renderer.ts",
// requireImportSource: true,
generate: "universal",
},
],
"@babel/typescript",
[
"@babel/env",
{
useBuiltIns: "usage",
corejs: "3.8.1",
},
],
],
});
return config;
}