Skip to content

Commit 4a50bb3

Browse files
Add nativescript.webpack.js
1 parent b045d84 commit 4a50bb3

File tree

4 files changed

+69
-17
lines changed

4 files changed

+69
-17
lines changed

README.md

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,6 @@ Use `on:raw-EventName` and `oncapture:RawEvent-Name` to register event handlers
5858

5959
To enable capture and bubble phase of an event, please refer to this [doc](https://github.com/SudoMaker/DOMiNATIVE#tweakabledefineeventoptioneventname-string-option-eventoption)
6060

61-
### Manually aliasing `solid-js`
62-
63-
You have to manually aliasing `solid-js` to the browser version in `webpack.config.js`, otherwise it will use the server version.
64-
65-
For example:
66-
67-
```js
68-
// Please keep this order of setting aliases
69-
config.resolve.alias
70-
.set("solid-js/universal", path.resolve(__dirname, `node_modules/solid-js/universal/dist/${env.production ? 'universal' : 'dev'}.js`))
71-
.set("solid-js", path.resolve(__dirname, `node_modules/solid-js/dist/${env.production ? 'solid' : 'dev'}.js`))
72-
```
73-
7461
## License
7562

7663
MIT

nativescript.webpack.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
const path = require('path');
2+
const {
3+
getPlatformName,
4+
} = require('@nativescript/webpack/dist/helpers/platform');
5+
6+
const solid = (config, env) => {
7+
const platform = getPlatformName();
8+
9+
const solidPath = path.resolve(require.resolve("solid-js"), "../..");
10+
11+
config.resolve.extensions
12+
.prepend('.js')
13+
.prepend('.ts')
14+
.prepend('.tsx')
15+
.prepend('.jsx')
16+
.prepend(`.${platform}.js`)
17+
.prepend(`.${platform}.ts`)
18+
.prepend(`.${platform}.jsx`)
19+
.prepend(`.${platform}.tsx`);
20+
21+
config.resolve.alias
22+
.set(
23+
'solid-js/universal',
24+
path.resolve(solidPath, `universal/dist/${env.production ? 'universal' : 'dev'}.js`)
25+
)
26+
.set(
27+
'solid-js',
28+
path.resolve(solidPath, `dist/${env.production ? 'solid' : 'dev'}.js`)
29+
);
30+
31+
config.module
32+
.rule('bundle-source')
33+
.test(/\.(|t|j)sx?$/)
34+
.exclude.add(/node_modules/)
35+
.end()
36+
.use('babel-loader')
37+
.loader('babel-loader')
38+
.before('ts-loader')
39+
.options({
40+
babelrc: false,
41+
configFile: false,
42+
presets: [
43+
[
44+
'babel-preset-solid',
45+
{
46+
moduleName: '@dominative/solid',
47+
generate: 'universal',
48+
},
49+
],
50+
],
51+
env: {
52+
development: {
53+
plugins: [['solid-refresh/babel', { bundler: 'webpack5' }]],
54+
},
55+
},
56+
});
57+
58+
if (!env.production) {
59+
config.output.devtoolNamespace('app');
60+
config.devServer.hotOnly(true);
61+
config.devServer.hot(true);
62+
}
63+
};
64+
65+
module.exports = webpack => webpack.chainWebpack(solid);
66+

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"name": "@dominative/solid",
3-
"version": "0.0.3-alpha.1",
3+
"version": "0.0.4-alpha.1",
44
"description": "Custom render and patches for SolidJS to work with DOMiNATIVE",
55
"main": "src/index.js",
6-
"type": "module",
76
"scripts": {},
87
"keywords": [
98
"{N}",

0 commit comments

Comments
 (0)