webpack.config.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. node: {
  15. fs: 'empty'
  16. },
  17. module: {
  18. rules: [
  19. {
  20. test: /\.tsx?$/,
  21. use: [{ loader: 'ts-loader', options: { context: process.cwd() } }]
  22. },
  23. {
  24. test: /\.js$/,
  25. use: ['source-map-loader'],
  26. enforce: 'pre',
  27. // eslint-disable-next-line no-undef
  28. exclude: /node_modules/
  29. },
  30. { test: /\.css$/, use: ['style-loader', 'css-loader'] },
  31. { test: /\.csv$/, use: 'raw-loader' },
  32. { test: /\.ipynb$/, use: 'json-loader' },
  33. { test: /\.html$/, use: 'file-loader' },
  34. { test: /\.md$/, use: 'raw-loader' },
  35. { test: /\.(jpg|png|gif)$/, use: 'file-loader' },
  36. { test: /\.js.map$/, use: 'file-loader' },
  37. {
  38. test: /\.woff2(\?v=\d+\.\d+\.\d+)?$/,
  39. use: 'url-loader?limit=10000&mimetype=application/font-woff'
  40. },
  41. {
  42. test: /\.woff(\?v=\d+\.\d+\.\d+)?$/,
  43. use: 'url-loader?limit=10000&mimetype=application/font-woff'
  44. },
  45. {
  46. test: /\.ttf(\?v=\d+\.\d+\.\d+)?$/,
  47. use: 'url-loader?limit=10000&mimetype=application/octet-stream'
  48. },
  49. { test: /\.eot(\?v=\d+\.\d+\.\d+)?$/, use: 'file-loader' },
  50. {
  51. // In .css files, svg is loaded as a data URI.
  52. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  53. issuer: { test: /\.css$/ },
  54. use: {
  55. loader: 'svg-url-loader',
  56. options: { encoding: 'none', limit: 10000 }
  57. }
  58. },
  59. {
  60. // In .ts and .tsx files (both of which compile to .js), svg files
  61. // must be loaded as a raw string instead of data URIs.
  62. test: /\.svg(\?v=\d+\.\d+\.\d+)?$/,
  63. issuer: { test: /\.js$/ },
  64. use: {
  65. loader: 'raw-loader'
  66. }
  67. }
  68. ]
  69. }
  70. };