京都のkintone用javascript
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

78 lines
1.9KB

  1. const webpack = require('webpack');
  2. const path = require('path');
  3. const glob = require('glob');
  4. const { exec } = require('child_process');
  5. const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
  6. const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
  7. const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
  8. const Dotenv = require('dotenv-webpack');
  9. const dotenv = require('dotenv');
  10. const { format } = require('date-fns');
  11. const basePath = path.resolve('src', 'apps');
  12. const env = dotenv.config().parsed
  13. // basePath配下の各ディレクトリを複数のentryとする
  14. const entries = glob.sync('**/index.+(js|ts|tsx)', { cwd: basePath }).reduce(
  15. (prev, file) => ({
  16. ...prev,
  17. [path.dirname(file)]: path.resolve(basePath, file),
  18. }),
  19. {}
  20. );
  21. module.exports = {
  22. entry: entries,
  23. cache: false,
  24. resolve: {
  25. // 拡張子を配列で指定
  26. extensions: [
  27. '.ts', '.js',
  28. ],
  29. plugins: [
  30. new TsconfigPathsPlugin({
  31. configFile: './tsconfig.json',
  32. }),
  33. ]
  34. },
  35. module: {
  36. rules: [
  37. {
  38. test: /\.m?js$/,
  39. exclude: /node_modules/,
  40. use: {
  41. loader: 'babel-loader',
  42. options: {
  43. presets: [
  44. [
  45. '@babel/preset-env',
  46. {
  47. useBuiltIns: 'usage',
  48. corejs: 3,
  49. },
  50. ],
  51. ],
  52. },
  53. },
  54. },
  55. {
  56. test: /\.tsx?$/,
  57. use: 'ts-loader',
  58. }
  59. ],
  60. },
  61. output: {
  62. path: path.resolve(__dirname, 'dist'),
  63. filename: '[name].js',
  64. },
  65. plugins: [
  66. // new Dotenv({ systemvars: true }),
  67. new ForkTsCheckerWebpackPlugin(),
  68. // new BundleAnalyzerPlugin(),
  69. new webpack.DefinePlugin({
  70. 'process.env.BUILD_TIME': JSON.stringify(format(new Date(), 'yyyy-MM-dd HH:mm:ss')),
  71. }),
  72. ],
  73. };