webpack.config.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. const webpack = require('webpack');
  2. module.exports = {
  3. entry: ['whatwg-fetch', './build/index.js'],
  4. output: {
  5. path: __dirname + '/build',
  6. filename: 'bundle.js'
  7. },
  8. bail: true,
  9. devtool: 'cheap-source-map',
  10. mode: 'production',
  11. module: {
  12. rules: [
  13. { test: /\.css$/, use: ['style-loader', 'css-loader'] },
  14. { test: /\.html$/, use: 'file-loader' },
  15. { test: /\.md$/, use: 'raw-loader' },
  16. {
  17. // In .css files, svg is loaded as a data URI.
  18. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  19. issuer: /\.css$/,
  20. use: {
  21. loader: 'svg-url-loader',
  22. options: { encoding: 'none', limit: 10000 }
  23. }
  24. },
  25. {
  26. // In .ts and .tsx files (both of which compile to .js), svg files
  27. // must be loaded as a raw string instead of data URIs.
  28. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  29. issuer: /\.js$/,
  30. use: {
  31. loader: 'raw-loader'
  32. }
  33. },
  34. {
  35. test: /\.(png|jpg|gif|ttf|woff|woff2|eot)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
  36. use: [{ loader: 'url-loader', options: { limit: 10000 } }]
  37. }
  38. ]
  39. },
  40. plugins: [
  41. new webpack.DefinePlugin({
  42. // Needed for Blueprint. See https://github.com/palantir/blueprint/issues/4393
  43. 'process.env': '{}',
  44. // Needed for various packages using cwd(), like the path polyfill
  45. process: { cwd: () => '/' }
  46. })
  47. ]
  48. };