plaid.conf.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. const { isProd } = require('@gera2ld/plaid/util');
  2. /**
  3. * For each entry, `key` is the chunk name, `value` has following properties:
  4. * - value.entry: webpack entry.
  5. * - value.html: options object passed to HtmlWebpackPlugin.
  6. * - value.html.inlineSource: if true, JS and CSS files will be inlined in HTML.
  7. */
  8. const htmlFactory = extra => options => ({
  9. ...options,
  10. title: 'Violentmonkey',
  11. ...extra,
  12. chunks: ['browser', ...options.chunks],
  13. });
  14. exports.pages = {
  15. 'browser': {
  16. entry: './src/common/browser',
  17. },
  18. 'background/index': {
  19. entry: './src/background',
  20. html: htmlFactory(),
  21. },
  22. 'options/index': {
  23. entry: './src/options',
  24. html: htmlFactory({
  25. js: [
  26. '/public/lib/zip.js/zip.js',
  27. ],
  28. }),
  29. },
  30. 'confirm/index': {
  31. entry: './src/confirm',
  32. html: htmlFactory(),
  33. },
  34. 'popup/index': {
  35. entry: './src/popup',
  36. html: htmlFactory(),
  37. },
  38. injected: {
  39. entry: './src/injected',
  40. },
  41. };
  42. exports.devServer = false;
  43. exports.devtool = isProd ? false : 'inline-source-map';
  44. exports.optimization = {
  45. runtimeChunk: false,
  46. splitChunks: {
  47. cacheGroups: {
  48. common: {
  49. name: 'common',
  50. minChunks: 2,
  51. chunks(chunk) {
  52. return ![
  53. 'browser',
  54. 'injected',
  55. ].includes(chunk.name);
  56. },
  57. },
  58. },
  59. },
  60. };