|
1 |
| -var path = require('path'); |
2 |
| -var version = require('./package.json').version; |
3 |
| -var crypto = require('crypto'); |
| 1 | +var path = require("path"); |
| 2 | +var crypto = require("crypto"); |
4 | 3 |
|
5 | 4 | // Workaround for loaders using "md4" by default, which is not supported in FIPS-compliant OpenSSL
|
6 | 5 | var cryptoOrigCreateHash = crypto.createHash;
|
7 | 6 | crypto.createHash = (algorithm) =>
|
8 |
| - cryptoOrigCreateHash(algorithm == 'md4' ? 'sha256' : algorithm); |
| 7 | + cryptoOrigCreateHash(algorithm == "md4" ? "sha256" : algorithm); |
9 | 8 |
|
10 | 9 | var rules = [
|
11 |
| - { |
12 |
| - test: /\.css$/, |
13 |
| - use: ['style-loader', 'css-loader'] |
14 |
| - }, |
15 |
| - { |
16 |
| - test: /\.(jpg|png|gif|svg)$/, |
17 |
| - use: [ |
18 |
| - { |
19 |
| - loader: 'file-loader', |
20 |
| - options: { |
21 |
| - esModule: false, |
22 |
| - } |
23 |
| - } |
24 |
| - ], |
25 |
| - } |
| 10 | + { test: /\.css$/, use: ["style-loader", "css-loader"] }, |
| 11 | + { test: /\.(jpg|png|gif|svg)$/i, type: "asset" }, |
26 | 12 | ];
|
27 | 13 |
|
28 | 14 | var resolve = {
|
29 |
| - fallback: { |
30 |
| - "crypto": require.resolve("crypto-browserify"), |
31 |
| - "buffer": require.resolve("buffer/"), |
32 |
| - "stream": require.resolve("stream-browserify") |
33 |
| - } |
| 15 | + fallback: { |
| 16 | + crypto: require.resolve("crypto-browserify"), |
| 17 | + buffer: require.resolve("buffer/"), |
| 18 | + stream: require.resolve("stream-browserify"), |
| 19 | + }, |
34 | 20 | };
|
35 | 21 |
|
36 | 22 | module.exports = [
|
37 |
| - {// Notebook extension |
38 |
| - entry: './src/extension.js', |
39 |
| - output: { |
40 |
| - filename: 'extension.js', |
41 |
| - path: path.resolve(__dirname, '..', 'ipyleaflet', 'nbextension'), |
42 |
| - libraryTarget: 'amd' |
43 |
| - }, |
44 |
| - resolve: resolve |
| 23 | + { |
| 24 | + // Notebook extension |
| 25 | + // |
| 26 | + // This bundle only contains the part of the JavaScript that is run on |
| 27 | + // load of the notebook. This section generally only performs |
| 28 | + // some configuration for requirejs, and provides the legacy |
| 29 | + // "load_ipython_extension" function which is required for any notebook |
| 30 | + // extension. |
| 31 | + entry: "./src/extension.js", |
| 32 | + output: { |
| 33 | + filename: "extension.js", |
| 34 | + path: path.resolve(__dirname, "..", "ipyleaflet", "nbextension"), |
| 35 | + libraryTarget: "amd", |
| 36 | + }, |
| 37 | + resolve: resolve, |
| 38 | + }, |
| 39 | + { |
| 40 | + // Bundle for the notebook containing the custom widget views and models |
| 41 | + // |
| 42 | + // This bundle contains the implementation for the custom widget views and |
| 43 | + // custom widget. |
| 44 | + // It must be an amd module |
| 45 | + entry: ["./amd-public-path.js", "./src/notebook.js"], |
| 46 | + output: { |
| 47 | + filename: "index.js", |
| 48 | + path: path.resolve(__dirname, "..", "ipyleaflet", "nbextension"), |
| 49 | + libraryTarget: "amd", |
| 50 | + publicPath: "", // Set in amd-public-path.js |
| 51 | + }, |
| 52 | + devtool: "source-map", |
| 53 | + module: { |
| 54 | + rules: rules, |
| 55 | + }, |
| 56 | + // 'module' is the magic requirejs dependency used to set the publicPath |
| 57 | + externals: ["@jupyter-widgets/base", "module"], |
| 58 | + resolve: resolve, |
| 59 | + }, |
| 60 | + { |
| 61 | + // Embeddable jupyter-leaflet bundle |
| 62 | + // |
| 63 | + // This bundle is identical to the notebook bundle containing the custom |
| 64 | + // widget views and models. The only difference is it is placed in the |
| 65 | + // dist/ directory and shipped with the npm package for use from a CDN |
| 66 | + // like jsdelivr. |
| 67 | + // |
| 68 | + // The target bundle is always `dist/index.js`, which is the path |
| 69 | + // required by the custom widget embedder. |
| 70 | + entry: ["./amd-public-path.js", "./src/embed.js"], |
| 71 | + output: { |
| 72 | + filename: "index.js", |
| 73 | + path: path.resolve(__dirname, "dist"), |
| 74 | + libraryTarget: "amd", |
| 75 | + publicPath: "", // Set in amd-public-path.js |
45 | 76 | },
|
46 |
| - {// jupyter-leaflet bundle for the classic notebook |
47 |
| - entry: './src/notebook.js', |
48 |
| - output: { |
49 |
| - filename: 'index.js', |
50 |
| - path: path.resolve(__dirname, '..', 'ipyleaflet', 'nbextension'), |
51 |
| - libraryTarget: 'amd', |
52 |
| - publicPath: '', |
53 |
| - }, |
54 |
| - devtool: 'source-map', |
55 |
| - module: { |
56 |
| - rules: rules |
57 |
| - }, |
58 |
| - externals: ['@jupyter-widgets/base'], |
59 |
| - resolve: resolve |
| 77 | + devtool: "source-map", |
| 78 | + module: { |
| 79 | + rules: rules, |
60 | 80 | },
|
61 |
| - {// jupyter-leaflet bundle for unpkg |
62 |
| - entry: './src/embed.js', |
63 |
| - output: { |
64 |
| - filename: 'index.js', |
65 |
| - path: path.resolve(__dirname, 'dist'), |
66 |
| - libraryTarget: 'amd', |
67 |
| - publicPath: 'https://unpkg.com/jupyter-leaflet@' + version + '/dist/' |
68 |
| - }, |
69 |
| - devtool: 'source-map', |
70 |
| - module: { |
71 |
| - rules: rules |
72 |
| - }, |
73 |
| - externals: ['@jupyter-widgets/base'], |
74 |
| - resolve: resolve |
75 |
| - } |
| 81 | + // 'module' is the magic requirejs dependency used to set the publicPath |
| 82 | + externals: ["@jupyter-widgets/base", "module"], |
| 83 | + resolve: resolve, |
| 84 | + }, |
76 | 85 | ];
|
0 commit comments