webpack.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Use sourcemaps if in watch or debug mode;
  2. const devtool =
  3. process.argv.indexOf('--watch') !== -1 ||
  4. process.argv.indexOf('--debug') !== -1
  5. ? 'source-map-inline'
  6. : 'eval';
  7. module.exports = {
  8. resolve: {
  9. extensions: ['.ts', '.tsx', '.js']
  10. },
  11. bail: true,
  12. devtool: devtool,
  13. mode: 'development',
  14. module: {
  15. rules: [
  16. {
  17. test: /\.tsx?$/,
  18. use: [{ loader: 'ts-loader', options: { context: process.cwd() } }]
  19. },
  20. {
  21. test: /\.js$/,
  22. use: ['source-map-loader'],
  23. enforce: 'pre',
  24. // eslint-disable-next-line no-undef
  25. exclude: /node_modules/
  26. },
  27. { test: /\.css$/, use: ['style-loader', 'css-loader'] },
  28. { test: /\.csv$/, use: 'raw-loader' },
  29. { test: /\.ipynb$/, use: 'json-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: { test: /\.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: { test: /\.js$/ },
  61. use: {
  62. loader: 'raw-loader'
  63. }
  64. }
  65. ]
  66. }
  67. };