-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathnativescript.webpack.js
75 lines (67 loc) · 1.79 KB
/
nativescript.webpack.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
const path = require('path');
const {
getPlatformName,
} = require('@nativescript/webpack/dist/helpers/platform');
const solid = (config, env) => {
const platform = getPlatformName();
const solidPath = path.resolve(require.resolve("solid-js"), "../..");
config.resolve.extensions
.prepend('.js')
.prepend('.ts')
.prepend('.tsx')
.prepend('.jsx')
.prepend(`.${platform}.js`)
.prepend(`.${platform}.ts`)
.prepend(`.${platform}.jsx`)
.prepend(`.${platform}.tsx`);
config.resolve.alias
.set(
'solid-js/universal',
path.resolve(solidPath, `universal/dist/${env.production ? 'universal' : 'dev'}.js`)
)
.set(
'solid-js/store',
path.resolve(solidPath, `store/dist/${env.production ? 'store' : 'dev'}.js`)
)
.set(
'solid-js',
path.resolve(solidPath, `dist/${env.production ? 'solid' : 'dev'}.js`)
)
.set(
'solid-js/web',
path.resolve(solidPath, `dist/${env.production ? 'web' : 'dev'}.js`)
);
config.module
.rule('bundle-source')
.test(/\.(|t|j)sx?$/)
.exclude.add(/node_modules/)
.end()
.use('babel-loader')
.loader('babel-loader')
.before('ts-loader')
.options({
babelrc: false,
configFile: false,
presets: [
[
'babel-preset-solid',
{
moduleName: '@nativescript-community/solid-js',
generate: 'universal',
},
],
"@babel/typescript"
],
env: {
development: {
plugins: [['solid-refresh/babel', { bundler: 'webpack5' }]],
},
},
});
if (!env.production) {
config.output.devtoolNamespace('app');
config.devServer.hotOnly(true);
config.devServer.hot(true);
}
};
module.exports = webpack => webpack.chainWebpack(solid);