Skip to content

Commit a564de9

Browse files
authored
Merge pull request #30 from cornhundred/patch-3
add embeddable bundle
2 parents 0643a04 + e5d9e60 commit a564de9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

{{cookiecutter.github_project_name}}/webpack.config.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ const rules = [
66

77
// Packages that shouldn't be bundled but loaded at runtime
88
const externals = ['@jupyter-widgets/base', 'three', 'jupyter-threejs'];
9+
var version = require('./package.json').version;
10+
var path = require('path');
911

1012
module.exports = [
1113
{
@@ -46,4 +48,36 @@ module.exports = [
4648
extensions: [".webpack.js", ".web.js", ".ts", ".js"]
4749
},
4850
},
51+
{// Embeddable {{ cookiecutter.npm_package_name }} bundle
52+
//
53+
// This bundle is generally almost identical to the notebook bundle
54+
// containing the custom widget views and models.
55+
//
56+
// The only difference is in the configuration of the webpack public path
57+
// for the static assets.
58+
//
59+
// It will be automatically distributed by unpkg to work with the static
60+
// widget embedder.
61+
//
62+
// The target bundle is always `dist/index.js`, which is the path required
63+
// by the custom widget embedder.
64+
//
65+
entry: './src/index.ts',
66+
output: {
67+
filename: 'index.js',
68+
path: path.resolve(__dirname, 'dist'),
69+
libraryTarget: 'amd',
70+
library: "{{ cookiecutter.npm_package_name }}",
71+
publicPath: 'https://unpkg.com/{{ cookiecutter.npm_package_name }}@' + version + '/dist/'
72+
},
73+
devtool: 'source-map',
74+
module: {
75+
rules: rules
76+
},
77+
externals: ['@jupyter-widgets/base'],
78+
resolve: {
79+
// Add '.ts' and '.tsx' as resolvable extensions.
80+
extensions: [".webpack.js", ".web.js", ".ts", ".js"]
81+
},
82+
}
4983
];

0 commit comments

Comments
 (0)