Skip to content

Commit 9ba634e

Browse files
authored
Merge pull request #36 from vidartf/fix-webpack
Fix webpack public path
2 parents 1fbc766 + 6e5113a commit 9ba634e

File tree

5 files changed

+32
-28
lines changed

5 files changed

+32
-28
lines changed

{{cookiecutter.github_project_name}}/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@types/expect.js": "^0.3.29",
5454
"@types/mocha": "^5.2.5",
5555
"@types/node": "^10.11.6",
56+
"@types/webpack-env": "^1.13.6",
5657
"expect.js": "^0.3.1",
5758
"fs-extra": "^7.0.0",
5859
"karma": "^3.0.0",
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) Jupyter Development Team.
2+
// Distributed under the terms of the Modified BSD License.
3+
4+
// Entry point for the notebook bundle containing custom model definitions.
5+
//
6+
// Setup notebook base URL
7+
//
8+
// Some static assets may be required by the custom widget javascript. The base
9+
// url for the notebook is not known at build time and is therefore computed
10+
// dynamically.
11+
__webpack_public_path__ = document.querySelector('body')!.getAttribute('data-base-url') + 'nbextensions/{{ cookiecutter.npm_package_name }}';
12+
13+
export * from './index';

{{cookiecutter.github_project_name}}/tests/karma.conf.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ module.exports = function (config) {
1111
},
1212
files: [
1313
{ pattern: "tests/src/**/*.ts" },
14-
{ pattern: "src/**/*.ts" }
14+
{ pattern: "src/**/*.ts" },
15+
],
16+
exclude: [
17+
"src/extension.ts",
1518
],
1619
preprocessors: {
1720
'**/*.ts': ['karma-typescript']

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

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,35 +6,38 @@ 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');
9+
const version = require('./package.json').version;
10+
const path = require('path');
11+
12+
13+
const resolve = {
14+
// Add '.ts' and '.tsx' as resolvable extensions.
15+
extensions: [".webpack.js", ".web.js", ".ts", ".js"]
16+
};
1117

1218
module.exports = [
1319
{
1420
// Notebook extension
15-
entry: './src/index.ts',
21+
entry: './src/extension.ts',
1622
output: {
1723
filename: 'index.js',
18-
path: __dirname + '/{{ cookiecutter.python_package_name }}/nbextension/static',
24+
path: path.resolve(__dirname, '{{ cookiecutter.python_package_name }}', 'nbextension', 'static'),
1925
libraryTarget: 'amd'
2026
},
2127
module: {
2228
rules: rules
2329
},
2430
devtool: 'source-map',
2531
externals: ['@jupyter-widgets/base'],
26-
resolve: {
27-
// Add '.ts' and '.tsx' as resolvable extensions.
28-
extensions: [".webpack.js", ".web.js", ".ts", ".js"]
29-
}
32+
resolve,
3033
},
3134

3235
{
3336
// embeddable bundle (e.g. for docs)
3437
entry: './src/index.ts',
3538
output: {
3639
filename: 'embed-bundle.js',
37-
path: __dirname + '/docs/source/_static',
40+
path: path.resolve(__dirname, 'docs', 'source', '_static'),
3841
library: "{{ cookiecutter.npm_package_name }}",
3942
libraryTarget: 'amd'
4043
},
@@ -43,10 +46,7 @@ module.exports = [
4346
},
4447
devtool: 'source-map',
4548
externals: ['@jupyter-widgets/base'],
46-
resolve: {
47-
// Add '.ts' and '.tsx' as resolvable extensions.
48-
extensions: [".webpack.js", ".web.js", ".ts", ".js"]
49-
},
49+
resolve,
5050
},
5151
{// Embeddable {{ cookiecutter.npm_package_name }} bundle
5252
//
@@ -75,9 +75,6 @@ module.exports = [
7575
rules: rules
7676
},
7777
externals: ['@jupyter-widgets/base'],
78-
resolve: {
79-
// Add '.ts' and '.tsx' as resolvable extensions.
80-
extensions: [".webpack.js", ".web.js", ".ts", ".js"]
81-
},
78+
resolve,
8279
}
8380
];

{{cookiecutter.github_project_name}}/{{cookiecutter.python_package_name}}/nbextension/static/extension.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
// Entry point for the notebook bundle containing custom model definitions.
2-
//
3-
// Setup notebook base URL
4-
//
5-
// Some static assets may be required by the custom widget javascript. The base
6-
// url for the notebook is not known at build time and is therefore computed
7-
// dynamically.
8-
__webpack_public_path__ = document.querySelector('body').getAttribute('data-base-url') + 'nbextensions/{{ cookiecutter.npm_package_name }}';
9-
10-
111
define(function() {
122
"use strict";
133

0 commit comments

Comments
 (0)