Skip to content

Commit

Permalink
Implement prod-specific mainfest
Browse files Browse the repository at this point in the history
  • Loading branch information
killergerbah committed Jan 9, 2024
1 parent 6f49720 commit 343deef
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion extension/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ const CopyPlugin = require('copy-webpack-plugin');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const glob = require('glob');

const modifyManifestForProduction = (content, options) => {
if (options.mode !== 'production') {
return content;
}

const manifest = JSON.parse(content.toString());
const modifiedContentScripts = manifest.content_scripts.map((originalContentScript) => ({
...originalContentScript,
exclude_globs: originalContentScript.exclude_globs?.filter((pattern) => !pattern.includes('localhost')),
matches: originalContentScript.matches?.filter((pattern) => !pattern.includes('localhost')),
}));
const modifiedManifest = { ...manifest, content_scripts: modifiedContentScripts };
return JSON.stringify(modifiedManifest);
};

module.exports = (env, options) => ({
entry: {
video: './src/video.ts',
Expand Down Expand Up @@ -66,13 +81,25 @@ module.exports = (env, options) => ({
{
from: './src',
globOptions: {
ignore: ['**/services', '**/handlers', '**/ui', '**/.DS_Store', '**/controllers', '**/*.ts'],
ignore: [
'**/services',
'**/handlers',
'**/ui',
'**/.DS_Store',
'**/controllers',
'**/*.ts',
'**/manifest.json',
],
},
},
{
from: '../common/locales',
to: 'asbplayer-locales',
},
{
from: './src/manifest.json',
transform: (content, path) => modifyManifestForProduction(content, options),
},
],
options: {
concurrency: 100,
Expand Down

0 comments on commit 343deef

Please sign in to comment.