| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- const { isProd } = require('@gera2ld/plaid/util');
- /**
- * For each entry, `key` is the chunk name, `value` has following properties:
- * - value.entry: webpack entry.
- * - value.html: options object passed to HtmlWebpackPlugin.
- * - value.html.inlineSource: if true, JS and CSS files will be inlined in HTML.
- */
- const injectTo = item => {
- if (!(item.attributes.src || '').endsWith('/index.js')) return 'head';
- };
- const htmlFactory = extra => options => ({
- ...options,
- title: 'Violentmonkey',
- ...extra,
- chunks: ['browser', ...options.chunks],
- injectTo,
- });
- exports.pages = {
- 'browser': {
- entry: './src/common/browser',
- },
- 'background/index': {
- entry: './src/background',
- html: htmlFactory(),
- },
- 'options/index': {
- entry: './src/options',
- html: htmlFactory(),
- },
- 'confirm/index': {
- entry: './src/confirm',
- html: htmlFactory(),
- },
- 'popup/index': {
- entry: './src/popup',
- html: htmlFactory(),
- },
- injected: {
- entry: './src/injected',
- },
- };
- const splitVendor = name => ({
- [name]: {
- test: new RegExp(`node_modules[/\\\\]${name}`),
- name: `public/lib/${name}`,
- chunks: 'all',
- priority: 100,
- },
- });
- exports.devServer = false;
- exports.devtool = isProd ? false : 'inline-source-map';
- exports.optimization = {
- runtimeChunk: false,
- splitChunks: {
- cacheGroups: {
- common: {
- name: 'common',
- minChunks: 2,
- enforce: true,
- chunks(chunk) {
- return ![
- 'browser',
- 'injected',
- ].includes(chunk.name);
- },
- },
- ...splitVendor('codemirror'),
- ...splitVendor('tldjs'),
- ...splitVendor('vue'),
- },
- },
- };
|