webpack.common.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. ],
  26. };
  27. module.exports = {
  28. entry: {
  29. app: './src/app.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'],
  52. },
  53. output: {
  54. path: path.resolve(__dirname, 'dist'),
  55. filename: '[name].bundle.js',
  56. },
  57. };