|
| 1 | +var version = require('./package.json').version; |
| 2 | + |
| 3 | +// Custom webpack loaders are generally the same for all webpack bundles, hence |
| 4 | +// stored in a separate local variable. |
| 5 | +var loaders = [ |
| 6 | + { test: /\.json$/, loader: 'json-loader' }, |
| 7 | +]; |
| 8 | + |
| 9 | + |
| 10 | +module.exports = [ |
| 11 | + {// Notebook extension |
| 12 | + // |
| 13 | + // This bundle only contains the part of the JavaScript that is run on |
| 14 | + // load of the notebook. This section generally only performs |
| 15 | + // some configuration for requirejs, and provides the legacy |
| 16 | + // "load_ipython_extension" function which is required for any notebook |
| 17 | + // extension. |
| 18 | + // |
| 19 | + entry: './src/extension.js', |
| 20 | + output: { |
| 21 | + filename: 'extension.js', |
| 22 | + path: '../{{ cookiecutter.python_package_name }}/static', |
| 23 | + libraryTarget: 'amd' |
| 24 | + } |
| 25 | + }, |
| 26 | + {// Bundle for the notebook containing the custom widget views and models |
| 27 | + // |
| 28 | + // This bundle contains the implementation for the custom widget views and |
| 29 | + // custom widget. |
| 30 | + // It must be an amd module |
| 31 | + // |
| 32 | + entry: './src/index.js', |
| 33 | + output: { |
| 34 | + filename: 'index.js', |
| 35 | + path: '../{{ cookiecutter.python_package_name }}/static', |
| 36 | + libraryTarget: 'amd' |
| 37 | + }, |
| 38 | + devtool: 'source-map', |
| 39 | + module: { |
| 40 | + loaders: loaders |
| 41 | + }, |
| 42 | + externals: ['jupyter-js-widgets'] |
| 43 | + }, |
| 44 | + {// Embeddable {{ cookiecutter.npm_package_name }} bundle |
| 45 | + // |
| 46 | + // This bundle is generally almost identical to the notebook bundle |
| 47 | + // containing the custom widget views and models. |
| 48 | + // |
| 49 | + // The only difference is in the configuration of the webpack public path |
| 50 | + // for the static assets. |
| 51 | + // |
| 52 | + // It will be automatically distributed by npmcdn to work with the static |
| 53 | + // widget embedder. |
| 54 | + // |
| 55 | + // The target bundle is always `dist/index.js`, which is the path required |
| 56 | + // by the custom widget embedder. |
| 57 | + // |
| 58 | + entry: './src/embed.js', |
| 59 | + output: { |
| 60 | + filename: 'index.js', |
| 61 | + path: './dist/', |
| 62 | + libraryTarget: 'amd', |
| 63 | + publicPath: 'https://npmcdn.com/{{ cookiecutter.npm_package_name }}@' + version + '/dist/' |
| 64 | + }, |
| 65 | + devtool: 'source-map', |
| 66 | + module: { |
| 67 | + loaders: loaders |
| 68 | + }, |
| 69 | + externals: ['jupyter-js-widgets'] |
| 70 | + } |
| 71 | +]; |
0 commit comments