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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. const path = require('path');
  2. const webpack = require('webpack');
  3. const TerserPlugin = require('terser-webpack-plugin');
  4. const pack = require('./package.json');
  5. module.exports = (env, argv) => ({
  6. entry: './src/main.ts',
  7. mode: argv.mode == 'development' ? 'development' : 'production',
  8. devtool: argv.mode == 'development' ? 'source-map' : undefined,
  9. output: {
  10. filename: !env.minimize ? 'martins.js' : 'martins.min.js',
  11. path: path.resolve(__dirname, 'dist'),
  12. publicPath: '/dist/',
  13. library: {
  14. name: 'Martins',
  15. type: 'umd',
  16. export: 'default',
  17. },
  18. },
  19. resolve: {
  20. extensions: [ '.ts', '.js' ],
  21. symlinks: false,
  22. modules: [
  23. path.resolve(__dirname, 'src'),
  24. path.resolve(__dirname, '../node_modules'),
  25. 'node_modules',
  26. ],
  27. },
  28. plugins: [
  29. new webpack.BannerPlugin({
  30. banner: ((({ author, version, year, homepage, description, date }) => ([
  31. `MARTINS.js Free Edition version ${version}`,
  32. `${description}`,
  33. `Copyright ${year} ${author}`,
  34. `${homepage}`,
  35. ``,
  36. `@license AGPL-3.0-only`,
  37. `Date: ${date}`,
  38. ].join('\n')))({
  39. ...pack,
  40. 'date': new Date().toISOString(),
  41. 'year': [ ...(new Set([2022, new Date().getFullYear()])) ].join('-'),
  42. 'author': pack.author.replace('@', '(at)'),
  43. }))
  44. }),
  45. new webpack.DefinePlugin({
  46. '__MARTINS_VERSION__': JSON.stringify(pack.version),
  47. '__MARTINS_DEVELOPMENT_MODE__': argv.mode == 'development',
  48. '__MARTINS_WEBSITE__': JSON.stringify(pack.homepage),
  49. }),
  50. new webpack.IgnorePlugin({
  51. resourceRegExp: /\.ignore\./i,
  52. }),
  53. ],
  54. module: {
  55. rules: [{
  56. test: /\.ts$/,
  57. include: path.resolve(__dirname, 'src'),
  58. exclude: /node_modules/,
  59. use: 'ts-loader',
  60. }],
  61. },
  62. devServer: {
  63. https: true,
  64. host: env.HOST || '0.0.0.0',
  65. port: env.PORT || 8000,
  66. static: ['demos', 'tests'].map(dir => ({
  67. directory: path.resolve(__dirname, dir),
  68. publicPath: `/${dir}/`,
  69. })),
  70. //host: '0.0.0.0',
  71. //host: 'local-ip',
  72. },
  73. optimization: !env.minimize ? { minimize: false } : {
  74. minimize: true,
  75. minimizer: [new TerserPlugin({
  76. terserOptions: {
  77. format: {
  78. comments: /@license/i,
  79. },
  80. },
  81. extractComments: false,
  82. })],
  83. },
  84. });