webpack.common.js 1.1 KB

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