webpack.config.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. // Copyright (c) Jupyter Development Team.
  2. // Distributed under the terms of the Modified BSD License.
  3. const data = require('./package.json');
  4. const webpack = require('webpack');
  5. const Build = require('@jupyterlab/builder').Build;
  6. // Generate webpack config to copy extension assets to the build directory,
  7. // such as setting schema files, theme assets, etc.
  8. const extensionAssetConfig = Build.ensureAssets({
  9. packageNames: data.jupyterlab.extensions,
  10. output: './build'
  11. });
  12. module.exports = [
  13. {
  14. entry: ['whatwg-fetch', './index.js'],
  15. output: {
  16. path: __dirname + '/build',
  17. filename: 'bundle.js'
  18. },
  19. bail: true,
  20. devtool: 'source-map',
  21. mode: 'development',
  22. module: {
  23. rules: [
  24. { test: /\.css$/, use: ['style-loader', 'css-loader'] },
  25. { test: /\.html$/, use: 'file-loader' },
  26. { test: /\.md$/, use: 'raw-loader' },
  27. { test: /\.(jpg|png|gif)$/, use: 'file-loader' },
  28. { test: /\.js.map$/, use: 'file-loader' },
  29. {
  30. test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
  31. use: 'url-loader?limit=10000&mimetype=application/font-woff'
  32. },
  33. {
  34. test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
  35. use: 'url-loader?limit=10000&mimetype=application/font-woff'
  36. },
  37. {
  38. test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
  39. use: 'url-loader?limit=10000&mimetype=application/octet-stream'
  40. },
  41. { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: 'file-loader' },
  42. {
  43. // In .css files, svg is loaded as a data URI.
  44. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  45. issuer: /\.css$/,
  46. use: {
  47. loader: 'svg-url-loader',
  48. options: { encoding: 'none', limit: 10000 }
  49. }
  50. },
  51. {
  52. // In .ts and .tsx files (both of which compile to .js), svg files
  53. // must be loaded as a raw string instead of data URIs.
  54. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  55. issuer: /\.js$/,
  56. use: {
  57. loader: 'raw-loader'
  58. }
  59. }
  60. ]
  61. },
  62. plugins: [
  63. new webpack.DefinePlugin({
  64. // Needed for Blueprint. See https://github.com/palantir/blueprint/issues/4393
  65. 'process.env': '{}',
  66. // Needed for various packages using cwd(), like the path polyfill
  67. process: { cwd: () => '/' }
  68. })
  69. ]
  70. }
  71. ].concat(extensionAssetConfig);