Skip to content

Commit 306f707

Browse files
committed
improved webpack and forms examples
1 parent 1816a06 commit 306f707

3 files changed

Lines changed: 73 additions & 53 deletions

File tree

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ coverage
88
docs/api
99
examples/storybook
1010
.history/
11-
docs/form-examples/main.js
11+
docs/form-examples/solid-ui.js

docs/FormsReadme.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ Run this instruction which will do all that for you.
5050
```
5151
npm run build-form-examples
5252
```
53-
2. Use the newly build solid-ui (called main.js) in your html.
54-
You need to use the new build main.js:
55-
* uncommenting the usage of the main.js script; Example [here](https://github.com/SolidOS/solid-ui/blob/4f620aea3e91daf5ce9591dd83d3c95c161a44ad/docs/form-examples/structures3.html#L21)
53+
2. Use the newly build solid-ui (called solid-ui.js) in your html.
54+
You need to use the new build solid-ui.js:
55+
* uncommenting the usage of the solid-ui.js script; Example [here](https://github.com/SolidOS/solid-ui/blob/4f620aea3e91daf5ce9591dd83d3c95c161a44ad/docs/form-examples/structures3.html#L21)
5656
* commenting out the mashlib.js usage. Example [here](https://github.com/SolidOS/solid-ui/blob/4f620aea3e91daf5ce9591dd83d3c95c161a44ad/docs/form-examples/structures3.html#L15)
5757

5858
3. Use your own rad data and form

webpack.config.js

Lines changed: 69 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,71 @@
1-
const path = require('path')
2-
const HtmlWebpackPlugin = require('html-webpack-plugin')
1+
const path = require('path');
2+
const HtmlWebpackPlugin = require('html-webpack-plugin');
33

4-
// module.exports = [{
5-
module.exports = (env, args) => {
6-
const production = args.mode === 'production'
7-
return {
8-
mode: args.mode || 'development',
9-
entry: './src/index.ts',
10-
output: {
11-
path: path.join(__dirname, '/dist/'),
12-
publicPath: '',
13-
filename: production ? 'solid-ui.min.js' : 'solid-ui.js',
14-
library: 'solid-ui',
15-
libraryTarget: 'umd'
16-
},
17-
plugins: [
18-
new HtmlWebpackPlugin() // plugin that creates in /lib the index.html that contains the webpack-bundle.js
19-
],
20-
externals: {
21-
fs: 'null',
22-
'node-fetch': 'fetch',
23-
'isomorphic-fetch': 'fetch',
24-
xmldom: 'window',
25-
'text-encoding': 'TextEncoder',
26-
'whatwg-url': 'window',
27-
'@trust/webcrypto': 'crypto'
28-
},
29-
resolve: {
30-
extensions: ['.ts', '.js'],
31-
fallback: { path: false }
32-
},
33-
devServer: {
34-
static: './dist'
35-
},
36-
devtool: 'source-map',
37-
module: {
38-
rules: [{
39-
test: /\.ts$/,
40-
use: 'babel-loader',
41-
exclude: /node_modules/
42-
}, {
43-
test: /\.sparql$/i,
44-
type: 'asset/source'
45-
}, {
46-
test: /\.ttl$/i,
47-
type: 'asset/source'
48-
}]
49-
}
4+
const common = {
5+
entry: './src/index.ts',
6+
output: {
7+
path: path.join(__dirname, '/dist/'),
8+
publicPath: '',
9+
library: 'solid-ui',
10+
libraryTarget: 'umd'
11+
},
12+
plugins: [
13+
new HtmlWebpackPlugin()
14+
],
15+
externals: {
16+
fs: 'null',
17+
'node-fetch': 'fetch',
18+
'isomorphic-fetch': 'fetch',
19+
xmldom: 'window',
20+
'text-encoding': 'TextEncoder',
21+
'whatwg-url': 'window',
22+
'@trust/webcrypto': 'crypto'
23+
},
24+
resolve: {
25+
extensions: ['.ts', '.js'],
26+
fallback: { path: false }
27+
},
28+
devServer: {
29+
static: './dist'
30+
},
31+
devtool: 'source-map',
32+
module: {
33+
rules: [{
34+
test: /\.ts$/,
35+
use: 'babel-loader',
36+
exclude: /node_modules/
37+
}, {
38+
test: /\.sparql$/i,
39+
type: 'asset/source'
40+
}, {
41+
test: /\.ttl$/i,
42+
type: 'asset/source'
43+
}]
5044
}
51-
}
45+
};
46+
47+
const minified = {
48+
...common,
49+
mode: 'production',
50+
output: {
51+
...common.output,
52+
filename: 'solid-ui.min.js'
53+
},
54+
optimization: {
55+
minimize: true
56+
}
57+
};
58+
59+
const unminified = {
60+
...common,
61+
mode: 'development',
62+
output: {
63+
...common.output,
64+
filename: 'solid-ui.js'
65+
},
66+
optimization: {
67+
minimize: false
68+
}
69+
};
70+
71+
module.exports = [minified, unminified];

0 commit comments

Comments
 (0)