webpack.common.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. // Target a version without class support due to this issue:
  4. // https://stackoverflow.com/q/43307607
  5. // This does not mean that we support Firefox <60ESR!
  6. // We will increase the target again once FF52 has died out.
  7. const minFirefoxTarget = 44;
  8. const babelOptions = {
  9. presets: [
  10. ['@babel/preset-env', {
  11. corejs: 3,
  12. useBuiltIns: 'entry',
  13. targets: {
  14. firefox: minFirefoxTarget,
  15. chrome: 65,
  16. opera: 52,
  17. safari: 11,
  18. },
  19. }],
  20. ],
  21. plugins: [
  22. ['@babel/plugin-transform-runtime', {
  23. regenerator: true,
  24. }],
  25. ['@babel/plugin-syntax-dynamic-import'],
  26. ],
  27. };
  28. module.exports = {
  29. entry: {
  30. app: './src/bootstrap.ts',
  31. },
  32. module: {
  33. rules: [
  34. {
  35. test: /\.ts$/,
  36. exclude: /node_modules/,
  37. use: [
  38. {loader: 'babel-loader', options: babelOptions},
  39. {loader: 'ts-loader'},
  40. ],
  41. },
  42. {
  43. test: /\.js$/,
  44. exclude: /node_modules/,
  45. use: [
  46. {loader: 'babel-loader', options: babelOptions},
  47. ],
  48. },
  49. ],
  50. },
  51. resolve: {
  52. extensions: ['.js', '.ts', '.wasm'],
  53. },
  54. output: {
  55. path: path.resolve(__dirname, 'dist', 'generated'),
  56. filename: '[name].bundle.js',
  57. chunkFilename: '[name].[chunkhash].bundle.js',
  58. },
  59. };