Skip to content

Commit 4c67fc6

Browse files
committed
Packing for web usage
1 parent a4a3985 commit 4c67fc6

6 files changed

Lines changed: 42 additions & 4 deletions

File tree

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,19 @@
11
# HDS JAVASCRIPT LIBRARY
2+
3+
Generic toolkit for server and web applications.
4+
5+
- [ ]
6+
7+
8+
## Usage
9+
10+
### Browser
11+
12+
```html
13+
<head>
14+
<script src="../docs/hds-lib.js"></script>"
15+
<script>
16+
model = new HDSLib.HDSModel();
17+
</script>
18+
</head>
19+
```

docs/bundle.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

docs/hds-lib.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index-webpack.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
/**
2+
* Export for webpack build
3+
*/
4+
export const HDSModel = require('./HDSModel');

tests-browser/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<html>
2+
<head>
3+
<script src="../docs/hds-lib.js"></script>"
4+
<script>
5+
console.log('>>', HDSLib, '<<');
6+
console.log('>>', new HDSLib.HDSModel(), '<<');
7+
/**
8+
const model = new HDSModel('https://model.datasafe.dev/pack.json');
9+
10+
(async () => {
11+
await model.load();
12+
})()**/
13+
</script>
14+
</head>
15+
</html>

webpack.config.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
const path = require('path');
22

33
module.exports = {
4-
entry: './src/index.js',
4+
entry: './src/index-webpack.js',
55
mode: 'production',
66
output: {
77
path: path.resolve(__dirname, 'docs'),
8-
filename: 'hds-lib.js'
8+
filename: 'hds-lib.js',
9+
globalObject: 'this',
10+
library: 'HDSLib'
911
}
1012
};

0 commit comments

Comments
 (0)