webpack.common.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 babelOptions = {
  8. presets: [
  9. ['@babel/preset-env', {
  10. corejs: 3,
  11. useBuiltIns: 'entry',
  12. targets: {
  13. firefox: 60,
  14. chrome: 65,
  15. opera: 52,
  16. safari: 11,
  17. },
  18. }],
  19. ],
  20. plugins: [
  21. ['@babel/plugin-transform-runtime', {
  22. regenerator: true,
  23. }],
  24. ['@babel/plugin-syntax-dynamic-import'],
  25. ],
  26. };
  27. module.exports = {
  28. entry: {
  29. app: './src/bootstrap.ts',
  30. },
  31. module: {
  32. rules: [
  33. {
  34. test: /\.ts$/,
  35. exclude: /node_modules/,
  36. use: [
  37. {loader: 'babel-loader', options: babelOptions},
  38. {loader: 'ts-loader'},
  39. ],
  40. },
  41. {
  42. test: /\.js$/,
  43. exclude: /node_modules/,
  44. use: [
  45. {loader: 'babel-loader', options: babelOptions},
  46. ],
  47. },
  48. ],
  49. },
  50. resolve: {
  51. extensions: ['.js', '.ts', '.wasm'],
  52. },
  53. output: {
  54. path: path.resolve(__dirname, 'dist', 'generated'),
  55. filename: '[name].bundle.js',
  56. chunkFilename: '[name].[chunkhash].bundle.js',
  57. },
  58. };