Skip to content

Commit c4cc53d

Browse files
committed
Publically hosted examples
1 parent 9b4b398 commit c4cc53d

5 files changed

Lines changed: 53 additions & 36 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ defined in JavaScript into the element.
1515

1616
## Examples
1717

18-
Have a look at the examples in example directory. The best way is to clone the repository and run it locally, so you can play around with the code.
18+
The examples in this crate are hosted online: [div-rs Examples](https://div.paddlers.ch/)
19+
20+
Have a look at the code in example directory. The best way is to clone the repository and run it locally, so you can play around with the code.
1921

2022
You need npm, webpack, and wasm-pack for the examples to run on your machine.
2123
```

examples/www/package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
},
99
"scripts": {
1010
"build": "wasm-pack build ../hello_svelte; wasm-pack build ../hello_world; wasm-pack build ../reposition/; wasm-pack build ../styled/; wasm-pack build ../toggle; webpack --config webpack.config.js",
11-
"start": "webpack-dev-server"
11+
"start": "webpack-dev-server",
12+
"release": "wasm-pack build ../hello_svelte; wasm-pack build ../hello_world; wasm-pack build ../reposition/; wasm-pack build ../styled/; wasm-pack build ../toggle; webpack --config webpack.prod.js"
1213
},
1314
"repository": {
1415
"type": "git",
@@ -35,12 +36,13 @@
3536
},
3637
"devDependencies": {
3738
"copy-webpack-plugin": "^5.0.0",
39+
"css-loader": "^4.3.0",
40+
"style-loader": "^1.2.1",
41+
"svelte": "^3.29.0",
42+
"svelte-loader": "^2.13.6",
3843
"webpack": "^4.29.3",
3944
"webpack-cli": "^3.1.0",
4045
"webpack-dev-server": "^3.1.5",
41-
"svelte": "^3.29.0",
42-
"css-loader": "^4.3.0",
43-
"style-loader": "^1.2.1",
44-
"svelte-loader": "^2.13.6"
46+
"webpack-merge": "^5.2.0"
4547
}
4648
}

examples/www/webpack.common.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
const CopyWebpackPlugin = require("copy-webpack-plugin");
2+
const path = require('path');
3+
4+
module.exports = {
5+
entry: "./bootstrap.js",
6+
output: {
7+
path: path.resolve(__dirname, "dist"),
8+
filename: "bootstrap.js",
9+
},
10+
resolve: {
11+
extensions: ['.mjs', '.js', '.svelte'],
12+
mainFields: ['svelte', 'browser', 'module', 'main'],
13+
modules: [path.resolve(__dirname, 'node_modules'), 'node_modules']
14+
},
15+
module: {
16+
rules: [{
17+
test: /\.(html|svelte)$/,
18+
exclude: /node_modules/,
19+
use: 'svelte-loader'
20+
}, {
21+
test: /\.css$/,
22+
use: [
23+
'style-loader',
24+
'css-loader'
25+
]
26+
}]
27+
},
28+
plugins: [
29+
new CopyWebpackPlugin(['index.html'])
30+
],
31+
};

examples/www/webpack.config.js

Lines changed: 5 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,7 @@
1-
const CopyWebpackPlugin = require("copy-webpack-plugin");
2-
const path = require('path');
1+
const { merge } = require('webpack-merge');
32

4-
module.exports = {
5-
entry: "./bootstrap.js",
6-
output: {
7-
path: path.resolve(__dirname, "dist"),
8-
filename: "bootstrap.js",
9-
},
3+
const common = require('./webpack.common.js');
4+
5+
module.exports = merge(common, {
106
mode: "development",
11-
resolve: {
12-
extensions: ['.mjs', '.js', '.svelte'],
13-
mainFields: ['svelte', 'browser', 'module', 'main'],
14-
modules: [path.resolve(__dirname, 'node_modules'), 'node_modules']
15-
},
16-
module: {
17-
rules: [{
18-
test: /\.(html|svelte)$/,
19-
exclude: /node_modules/,
20-
use: 'svelte-loader'
21-
}, {
22-
test: /\.css$/,
23-
use: [
24-
'style-loader',
25-
'css-loader'
26-
]
27-
}]
28-
},
29-
plugins: [
30-
new CopyWebpackPlugin(['index.html'])
31-
],
32-
};
7+
});

examples/www/webpack.prod.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
const { merge } = require('webpack-merge');
2+
3+
const common = require('./webpack.common.js');
4+
5+
module.exports = merge(common, {
6+
mode: "production",
7+
});

0 commit comments

Comments
 (0)