webpack.config.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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/buildutils').Build;
  6. const names = Object.keys(data.dependencies).filter(function(name) {
  7. const packageData = require(name + '/package.json');
  8. return packageData.jupyterlab !== undefined;
  9. });
  10. const extras = Build.ensureAssets({
  11. packageNames: names,
  12. output: './build'
  13. });
  14. module.exports = [
  15. {
  16. entry: ['whatwg-fetch', './index.js'],
  17. output: {
  18. path: __dirname + '/build',
  19. filename: 'bundle.js'
  20. },
  21. // node: {
  22. // fs: 'empty'
  23. // },
  24. bail: true,
  25. devtool: 'source-map',
  26. mode: 'development',
  27. module: {
  28. rules: [
  29. { test: /\.css$/, use: ['style-loader', 'css-loader'] },
  30. { test: /\.html$/, use: 'file-loader' },
  31. { test: /\.md$/, use: 'raw-loader' },
  32. { test: /\.(jpg|png|gif)$/, use: 'file-loader' },
  33. { test: /\.js.map$/, use: 'file-loader' },
  34. {
  35. test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
  36. use: 'url-loader?limit=10000&mimetype=application/font-woff'
  37. },
  38. {
  39. test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
  40. use: 'url-loader?limit=10000&mimetype=application/font-woff'
  41. },
  42. {
  43. test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
  44. use: 'url-loader?limit=10000&mimetype=application/octet-stream'
  45. },
  46. { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: 'file-loader' },
  47. {
  48. // In .css files, svg is loaded as a data URI.
  49. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  50. issuer: /\.css$/,
  51. use: {
  52. loader: 'svg-url-loader',
  53. options: { encoding: 'none', limit: 10000 }
  54. }
  55. },
  56. {
  57. // In .ts and .tsx files (both of which compile to .js), svg files
  58. // must be loaded as a raw string instead of data URIs.
  59. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  60. issuer: /\.js$/,
  61. use: {
  62. loader: 'raw-loader'
  63. }
  64. }
  65. ]
  66. },
  67. plugins: [
  68. new webpack.DefinePlugin({
  69. 'process.env': '{}',
  70. process: {}
  71. })
  72. ]
  73. }
  74. ].concat(extras);