Skip to content

Update public path to auto, and update example configs #3464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion examples/web1/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
"devDependencies": {
"chai": "^4.0.0",
"css-loader": "^6.5.1",
"file-loader": "^6.2.0",
"karma": "^6.3.3",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
Expand Down
8 changes: 2 additions & 6 deletions examples/web1/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,14 @@ var webpack = require('webpack');

module.exports = {
mode: 'development',
devtool: 'source-map',
entry: './index.js',
output: {
filename: 'index.built.js',
path: path.resolve(__dirname, 'built'),
publicPath: 'built/',
},
module: {
rules: [
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, use: 'file-loader' },
],
rules: [{ test: /\.css$/i, use: ['style-loader', 'css-loader'] }],
},
plugins: [
new webpack.DefinePlugin({
Expand Down
2 changes: 1 addition & 1 deletion examples/web2/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ require('@jupyter-widgets/controls/css/widgets.css');
require('font-awesome/css/font-awesome.css');

document.addEventListener('DOMContentLoaded', function (event) {
var code = require('./widget_code.py').default;
var code = require('./widget_code.py');
var inputarea = document.getElementsByClassName('inputarea')[0];
new CodeMirror(inputarea, {
value: code,
Expand Down
3 changes: 0 additions & 3 deletions examples/web2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
},
"devDependencies": {
"css-loader": "^6.5.1",
"file-loader": "^6.2.0",
"raw-loader": "^4.0.2",
"style-loader": "^3.3.1",
"url-loader": "^4.1.1",
"webpack": "^5.65.0"
}
}
51 changes: 5 additions & 46 deletions examples/web2/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,60 +3,19 @@ var webpack = require('webpack');

module.exports = {
mode: 'development',
devtool: 'source-map',
entry: './index.js',
output: {
filename: 'index.built.js',
path: path.resolve(__dirname, 'built'),
publicPath: 'built/',
},
module: {
rules: [
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.py$/, use: 'raw-loader' },
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, use: 'file-loader' },
{ test: /\.css$/i, use: ['style-loader', 'css-loader'] },
{ test: /\.py$/i, type: 'asset/source' },
// required to load font-awesome
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/font-woff',
},
},
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/font-woff',
},
},
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/octet-stream',
},
},
},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: 'file-loader' },
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'image/svg+xml',
},
},
},
{ test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource' },
{ test: /\.svg$/i, type: 'asset' },
],
},
plugins: [
Expand Down
6 changes: 0 additions & 6 deletions examples/web3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,10 @@
"@types/codemirror": "^5.60.0",
"@types/node": "^17.0.2",
"css-loader": "^6.5.1",
"file-loader": "^6.2.0",
"fs-extra": "^10.0.0",
"postcss": "^8.3.2",
"postcss-cssnext": "^3.1.0",
"postcss-import": "^14.0.2",
"postcss-loader": "^6.1.0",
"rimraf": "^3.0.2",
"style-loader": "^3.3.1",
"typescript": "~4.3.2",
"url-loader": "^4.1.1",
"webpack": "^5.65.0"
}
}
80 changes: 4 additions & 76 deletions examples/web3/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,90 +4,18 @@ const webpack = require('webpack');

module.exports = {
mode: 'development',
devtool: 'source-map',
entry: './lib/index.js',
output: {
filename: 'index.built.js',
path: path.resolve(__dirname, 'built'),
publicPath: 'built/',
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader',
{
loader: 'postcss-loader',
options: {
postcssOptions: {
plugins: [
postcss.plugin('delete-tilde', function () {
return function (css) {
css.walkAtRules('import', function (rule) {
rule.params = rule.params.replace('~', '');
});
};
}),
postcss.plugin('prepend', function () {
return function (css) {
css.prepend(
"@import '@jupyter-widgets/controls/css/labvariables.css';"
);
};
}),
require('postcss-import')(),
require('postcss-cssnext')(),
],
},
},
},
],
},
// jquery-ui loads some images
{ test: /\.(jpg|png|gif)$/, use: 'file-loader' },
{ test: /\.css$/i, use: ['style-loader', 'css-loader'] },
// required to load font-awesome
{
test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/font-woff',
},
},
},
{
test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/font-woff',
},
},
},
{
test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'application/octet-stream',
},
},
},
{ test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: 'file-loader' },
{
test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
use: {
loader: 'url-loader',
options: {
limit: 10000,
mimetype: 'image/svg+xml',
},
},
},
{ test: /\.(woff|woff2|eot|ttf|otf)$/i, type: 'asset/resource' },
{ test: /\.svg$/i, type: 'asset' },
],
},
plugins: [
Expand Down
11 changes: 11 additions & 0 deletions examples/web4/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ semver range. For example:

`<script src="https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@^0.8.0/dist/embed.js" crossorigin="anonymous"></script>`

The widget data in this example was generated from the following code:

```python
from ipywidgets import VBox, jsdlink, IntSlider, Button

s1, s2 = IntSlider(max=200, value=100), IntSlider(value=40)
b = Button(icon='legal')
jsdlink((s1, 'value'), (s2, 'max'))
VBox([s1, s2, b])
```

## Try it

1. Start with a repository checkout, and run `yarn install` in the root directory.
Expand Down
Loading