You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

335 lines
9.0 KiB

Add Octicon SVG spritemap (#10107) * Add octicon SVG sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Static prefix Signed-off-by: jolheiser <john.olheiser@gmail.com> * SVG for all repo icons Signed-off-by: jolheiser <john.olheiser@gmail.com> * make vendor Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap out octicons Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move octicons to top of less imports Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Definitely not a search/replace Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed regex Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move to more generic calls and webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * make svg -> make webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg-sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed a test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg from makefile Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Attempt to fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert timetracking test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap .octicon for .svg in less Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add aria-hidden Signed-off-by: jolheiser <john.olheiser@gmail.com> * Replace mega-octicon Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix webpack globbing on Windows Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert Co-Authored-By: silverwind <me@silverwind.io> * Fix octions from upstream Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix Vue and missed JS function Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add JS helper and PWA Signed-off-by: jolheiser <john.olheiser@gmail.com> * Preload SVG Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net>
4 years ago
Add Octicon SVG spritemap (#10107) * Add octicon SVG sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Static prefix Signed-off-by: jolheiser <john.olheiser@gmail.com> * SVG for all repo icons Signed-off-by: jolheiser <john.olheiser@gmail.com> * make vendor Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap out octicons Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move octicons to top of less imports Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Definitely not a search/replace Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed regex Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move to more generic calls and webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * make svg -> make webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg-sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed a test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg from makefile Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Attempt to fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert timetracking test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap .octicon for .svg in less Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add aria-hidden Signed-off-by: jolheiser <john.olheiser@gmail.com> * Replace mega-octicon Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix webpack globbing on Windows Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert Co-Authored-By: silverwind <me@silverwind.io> * Fix octions from upstream Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix Vue and missed JS function Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add JS helper and PWA Signed-off-by: jolheiser <john.olheiser@gmail.com> * Preload SVG Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net>
4 years ago
Add Octicon SVG spritemap (#10107) * Add octicon SVG sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Static prefix Signed-off-by: jolheiser <john.olheiser@gmail.com> * SVG for all repo icons Signed-off-by: jolheiser <john.olheiser@gmail.com> * make vendor Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap out octicons Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move octicons to top of less imports Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Definitely not a search/replace Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed regex Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move to more generic calls and webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * make svg -> make webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg-sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed a test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg from makefile Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Attempt to fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert timetracking test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap .octicon for .svg in less Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add aria-hidden Signed-off-by: jolheiser <john.olheiser@gmail.com> * Replace mega-octicon Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix webpack globbing on Windows Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert Co-Authored-By: silverwind <me@silverwind.io> * Fix octions from upstream Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix Vue and missed JS function Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add JS helper and PWA Signed-off-by: jolheiser <john.olheiser@gmail.com> * Preload SVG Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net>
4 years ago
Add Octicon SVG spritemap (#10107) * Add octicon SVG sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Static prefix Signed-off-by: jolheiser <john.olheiser@gmail.com> * SVG for all repo icons Signed-off-by: jolheiser <john.olheiser@gmail.com> * make vendor Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap out octicons Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move octicons to top of less imports Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Definitely not a search/replace Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed regex Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move to more generic calls and webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * make svg -> make webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg-sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed a test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg from makefile Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Attempt to fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert timetracking test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap .octicon for .svg in less Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add aria-hidden Signed-off-by: jolheiser <john.olheiser@gmail.com> * Replace mega-octicon Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix webpack globbing on Windows Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert Co-Authored-By: silverwind <me@silverwind.io> * Fix octions from upstream Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix Vue and missed JS function Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add JS helper and PWA Signed-off-by: jolheiser <john.olheiser@gmail.com> * Preload SVG Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net>
4 years ago
Add Octicon SVG spritemap (#10107) * Add octicon SVG sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Static prefix Signed-off-by: jolheiser <john.olheiser@gmail.com> * SVG for all repo icons Signed-off-by: jolheiser <john.olheiser@gmail.com> * make vendor Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap out octicons Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move octicons to top of less imports Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Definitely not a search/replace Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed regex Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move to more generic calls and webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * make svg -> make webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg-sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed a test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg from makefile Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Attempt to fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert timetracking test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap .octicon for .svg in less Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add aria-hidden Signed-off-by: jolheiser <john.olheiser@gmail.com> * Replace mega-octicon Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix webpack globbing on Windows Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert Co-Authored-By: silverwind <me@silverwind.io> * Fix octions from upstream Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix Vue and missed JS function Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add JS helper and PWA Signed-off-by: jolheiser <john.olheiser@gmail.com> * Preload SVG Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net>
4 years ago
Add Octicon SVG spritemap (#10107) * Add octicon SVG sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Static prefix Signed-off-by: jolheiser <john.olheiser@gmail.com> * SVG for all repo icons Signed-off-by: jolheiser <john.olheiser@gmail.com> * make vendor Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap out octicons Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move octicons to top of less imports Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Definitely not a search/replace Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed regex Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move to more generic calls and webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * make svg -> make webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg-sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed a test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg from makefile Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Attempt to fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert timetracking test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap .octicon for .svg in less Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add aria-hidden Signed-off-by: jolheiser <john.olheiser@gmail.com> * Replace mega-octicon Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix webpack globbing on Windows Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert Co-Authored-By: silverwind <me@silverwind.io> * Fix octions from upstream Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix Vue and missed JS function Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add JS helper and PWA Signed-off-by: jolheiser <john.olheiser@gmail.com> * Preload SVG Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net>
4 years ago
Add Octicon SVG spritemap (#10107) * Add octicon SVG sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Static prefix Signed-off-by: jolheiser <john.olheiser@gmail.com> * SVG for all repo icons Signed-off-by: jolheiser <john.olheiser@gmail.com> * make vendor Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap out octicons Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move octicons to top of less imports Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Definitely not a search/replace Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed regex Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move to more generic calls and webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * make svg -> make webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg-sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed a test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg from makefile Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Attempt to fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert timetracking test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap .octicon for .svg in less Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add aria-hidden Signed-off-by: jolheiser <john.olheiser@gmail.com> * Replace mega-octicon Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix webpack globbing on Windows Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert Co-Authored-By: silverwind <me@silverwind.io> * Fix octions from upstream Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix Vue and missed JS function Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add JS helper and PWA Signed-off-by: jolheiser <john.olheiser@gmail.com> * Preload SVG Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net>
4 years ago
Add Octicon SVG spritemap (#10107) * Add octicon SVG sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Static prefix Signed-off-by: jolheiser <john.olheiser@gmail.com> * SVG for all repo icons Signed-off-by: jolheiser <john.olheiser@gmail.com> * make vendor Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap out octicons Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move octicons to top of less imports Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix JS Signed-off-by: jolheiser <john.olheiser@gmail.com> * Definitely not a search/replace Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed regex Signed-off-by: jolheiser <john.olheiser@gmail.com> * Move to more generic calls and webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * make svg -> make webpack Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg-sprite Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Missed a test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Remove svg from makefile Signed-off-by: jolheiser <john.olheiser@gmail.com> * Suggestions Signed-off-by: jolheiser <john.olheiser@gmail.com> * Attempt to fix test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Update tests Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert timetracking test Signed-off-by: jolheiser <john.olheiser@gmail.com> * Swap .octicon for .svg in less Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add aria-hidden Signed-off-by: jolheiser <john.olheiser@gmail.com> * Replace mega-octicon Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix webpack globbing on Windows Signed-off-by: jolheiser <john.olheiser@gmail.com> * Revert Co-Authored-By: silverwind <me@silverwind.io> * Fix octions from upstream Signed-off-by: jolheiser <john.olheiser@gmail.com> * Fix Vue and missed JS function Signed-off-by: jolheiser <john.olheiser@gmail.com> * Add JS helper and PWA Signed-off-by: jolheiser <john.olheiser@gmail.com> * Preload SVG Signed-off-by: jolheiser <john.olheiser@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: techknowlogick <matti@mdranta.net>
4 years ago
  1. const fastGlob = require('fast-glob');
  2. const wrapAnsi = require('wrap-ansi');
  3. const CssNanoPlugin = require('cssnano-webpack-plugin');
  4. const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
  5. const MiniCssExtractPlugin = require('mini-css-extract-plugin');
  6. const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
  7. const PostCSSPresetEnv = require('postcss-preset-env');
  8. const SpriteLoaderPlugin = require('svg-sprite-loader/plugin');
  9. const TerserPlugin = require('terser-webpack-plugin');
  10. const VueLoaderPlugin = require('vue-loader/lib/plugin');
  11. const {statSync} = require('fs');
  12. const {resolve, parse} = require('path');
  13. const {LicenseWebpackPlugin} = require('license-webpack-plugin');
  14. const {SourceMapDevToolPlugin} = require('webpack');
  15. const glob = (pattern) => fastGlob.sync(pattern, {cwd: __dirname, absolute: true});
  16. const themes = {};
  17. for (const path of glob('web_src/less/themes/*.less')) {
  18. themes[parse(path).name] = [path];
  19. }
  20. const isProduction = process.env.NODE_ENV !== 'development';
  21. const filterCssImport = (parsedImport, cssFile) => {
  22. const url = parsedImport && parsedImport.url ? parsedImport.url : parsedImport;
  23. const importedFile = url.replace(/[?#].+/, '').toLowerCase();
  24. if (/vendor\/assets/.test(url)) return false; // font imports
  25. if (/web_src[/\\]less/.test(cssFile)) return true; // relative imports
  26. if (cssFile.includes('monaco')) return true;
  27. if (cssFile.includes('fomantic')) {
  28. if (/brand-icons/.test(importedFile)) return false;
  29. if (/(eot|ttf|woff)$/.test(importedFile)) return false;
  30. return true;
  31. }
  32. return cssFile.includes('node_modules');
  33. };
  34. module.exports = {
  35. mode: isProduction ? 'production' : 'development',
  36. entry: {
  37. index: [
  38. resolve(__dirname, 'web_src/js/jquery.js'),
  39. resolve(__dirname, 'web_src/fomantic/build/semantic.js'),
  40. resolve(__dirname, 'web_src/js/index.js'),
  41. resolve(__dirname, 'web_src/fomantic/build/semantic.css'),
  42. resolve(__dirname, 'web_src/less/index.less'),
  43. ],
  44. swagger: [
  45. resolve(__dirname, 'web_src/js/standalone/swagger.js'),
  46. ],
  47. serviceworker: [
  48. resolve(__dirname, 'web_src/js/serviceworker.js'),
  49. ],
  50. 'eventsource.sharedworker': [
  51. resolve(__dirname, 'web_src/js/features/eventsource.sharedworker.js'),
  52. ],
  53. icons: [
  54. ...glob('node_modules/@primer/octicons/build/svg/**/*.svg'),
  55. ...glob('assets/svg/*.svg'),
  56. ],
  57. ...themes,
  58. },
  59. devtool: false,
  60. output: {
  61. path: resolve(__dirname, 'public'),
  62. filename: ({chunk}) => {
  63. // serviceworker can only manage assets below it's script's directory so
  64. // we have to put it in / instead of /js/
  65. return chunk.name === 'serviceworker' ? '[name].js' : 'js/[name].js';
  66. },
  67. chunkFilename: 'js/[name].js',
  68. },
  69. optimization: {
  70. minimize: isProduction,
  71. minimizer: [
  72. new TerserPlugin({
  73. sourceMap: true,
  74. extractComments: false,
  75. terserOptions: {
  76. output: {
  77. comments: false,
  78. },
  79. },
  80. }),
  81. new CssNanoPlugin({
  82. sourceMap: true,
  83. cssnanoOptions: {
  84. preset: [
  85. 'default',
  86. {
  87. discardComments: {
  88. removeAll: true,
  89. },
  90. },
  91. ],
  92. },
  93. }),
  94. ],
  95. splitChunks: {
  96. chunks: 'async',
  97. name: (_, chunks) => chunks.map((item) => item.name).join('-'),
  98. cacheGroups: {
  99. // this bundles all monaco's languages into one file instead of emitting 1-65.js files
  100. monaco: {
  101. test: /monaco-editor/,
  102. name: 'monaco',
  103. chunks: 'async',
  104. },
  105. },
  106. },
  107. },
  108. module: {
  109. rules: [
  110. {
  111. test: /\.vue$/,
  112. exclude: /node_modules/,
  113. loader: 'vue-loader',
  114. },
  115. {
  116. test: /\.worker\.js$/,
  117. exclude: /monaco/,
  118. use: [
  119. {
  120. loader: 'worker-loader',
  121. options: {
  122. name: '[name].js',
  123. inline: true,
  124. fallback: false,
  125. },
  126. },
  127. ],
  128. },
  129. {
  130. test: /\.js$/,
  131. exclude: /node_modules/,
  132. use: [
  133. {
  134. loader: 'babel-loader',
  135. options: {
  136. cacheDirectory: true,
  137. cacheCompression: false,
  138. cacheIdentifier: [
  139. resolve(__dirname, 'package.json'),
  140. resolve(__dirname, 'package-lock.json'),
  141. resolve(__dirname, 'webpack.config.js'),
  142. ].map((path) => statSync(path).mtime.getTime()).join(':'),
  143. sourceMaps: true,
  144. presets: [
  145. [
  146. '@babel/preset-env',
  147. {
  148. useBuiltIns: 'usage',
  149. corejs: 3,
  150. },
  151. ],
  152. ],
  153. plugins: [
  154. [
  155. '@babel/plugin-transform-runtime',
  156. {
  157. regenerator: true,
  158. }
  159. ],
  160. '@babel/plugin-proposal-object-rest-spread',
  161. ],
  162. generatorOpts: {
  163. compact: false,
  164. },
  165. },
  166. },
  167. ],
  168. },
  169. {
  170. test: /.css$/i,
  171. use: [
  172. {
  173. loader: MiniCssExtractPlugin.loader,
  174. },
  175. {
  176. loader: 'css-loader',
  177. options: {
  178. importLoaders: 1,
  179. url: filterCssImport,
  180. import: filterCssImport,
  181. sourceMap: true,
  182. },
  183. },
  184. {
  185. loader: 'postcss-loader',
  186. options: {
  187. plugins: () => [
  188. PostCSSPresetEnv(),
  189. ],
  190. sourceMap: true,
  191. },
  192. },
  193. ],
  194. },
  195. {
  196. test: /.less$/i,
  197. use: [
  198. {
  199. loader: MiniCssExtractPlugin.loader,
  200. },
  201. {
  202. loader: 'css-loader',
  203. options: {
  204. importLoaders: 2,
  205. url: filterCssImport,
  206. import: filterCssImport,
  207. sourceMap: true,
  208. },
  209. },
  210. {
  211. loader: 'postcss-loader',
  212. options: {
  213. plugins: () => [
  214. PostCSSPresetEnv(),
  215. ],
  216. sourceMap: true,
  217. },
  218. },
  219. {
  220. loader: 'less-loader',
  221. options: {
  222. sourceMap: true,
  223. },
  224. },
  225. ],
  226. },
  227. {
  228. test: /\.svg$/,
  229. use: [
  230. {
  231. loader: 'svg-sprite-loader',
  232. options: {
  233. extract: true,
  234. spriteFilename: 'img/svg/icons.svg',
  235. symbolId: (path) => {
  236. const {name} = parse(path);
  237. if (/@primer[/\\]octicons/.test(path)) {
  238. return `octicon-${name}`;
  239. }
  240. return name;
  241. },
  242. },
  243. },
  244. {
  245. loader: 'svgo-loader',
  246. },
  247. ],
  248. },
  249. {
  250. test: /\.(ttf|woff2?)$/,
  251. use: [
  252. {
  253. loader: 'file-loader',
  254. options: {
  255. name: '[name].[ext]',
  256. outputPath: 'fonts/',
  257. publicPath: (url) => `../fonts/${url}`, // seems required for monaco's font
  258. },
  259. },
  260. ],
  261. },
  262. ],
  263. },
  264. plugins: [
  265. new VueLoaderPlugin(),
  266. // avoid generating useless js output files for css- and svg-only chunks
  267. new FixStyleOnlyEntriesPlugin({
  268. extensions: ['less', 'scss', 'css', 'svg'],
  269. silent: true,
  270. }),
  271. new MiniCssExtractPlugin({
  272. filename: 'css/[name].css',
  273. chunkFilename: 'css/[name].css',
  274. }),
  275. new SourceMapDevToolPlugin({
  276. filename: '[file].map',
  277. include: [
  278. 'js/index.js',
  279. 'css/index.css',
  280. ],
  281. }),
  282. new SpriteLoaderPlugin({
  283. plainSprite: true,
  284. }),
  285. new MonacoWebpackPlugin({
  286. filename: 'js/monaco-[name].worker.js',
  287. }),
  288. new LicenseWebpackPlugin({
  289. outputFilename: 'js/licenses.txt',
  290. perChunkOutput: false,
  291. addBanner: false,
  292. skipChildCompilers: true,
  293. modulesDirectories: [
  294. resolve(__dirname, 'node_modules'),
  295. ],
  296. renderLicenses: (modules) => {
  297. const line = '-'.repeat(80);
  298. return modules.map((module) => {
  299. const {name, version} = module.packageJson;
  300. const {licenseId, licenseText} = module;
  301. const body = wrapAnsi(licenseText || '', 80);
  302. return `${line}\n${name}@${version} - ${licenseId}\n${line}\n${body}`;
  303. }).join('\n');
  304. },
  305. stats: {
  306. warnings: false,
  307. errors: true,
  308. },
  309. }),
  310. ],
  311. performance: {
  312. hints: false,
  313. maxEntrypointSize: Infinity,
  314. maxAssetSize: Infinity,
  315. },
  316. resolve: {
  317. symlinks: false,
  318. alias: {
  319. vue$: 'vue/dist/vue.esm.js', // needed because vue's default export is the runtime only
  320. },
  321. },
  322. watchOptions: {
  323. ignored: [
  324. 'node_modules/**',
  325. ],
  326. },
  327. stats: {
  328. children: false,
  329. },
  330. };