mirror of
https://github.com/abhijithvijayan/web-extension-starter.git
synced 2026-01-30 09:48:12 +01:00
feat: use wext-manifest to generate manifest.json for target browser
This commit is contained in:
parent
fbf1cb18de
commit
ded5f90d4b
@ -1,13 +1,18 @@
|
|||||||
const path = require('path');
|
const path = require('path');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
|
const wextManifest = require('wext-manifest');
|
||||||
const ZipPlugin = require('zip-webpack-plugin');
|
const ZipPlugin = require('zip-webpack-plugin');
|
||||||
const TerserPlugin = require('terser-webpack-plugin');
|
const TerserPlugin = require('terser-webpack-plugin');
|
||||||
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
const CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const WriteWebpackPlugin = require('write-webpack-plugin');
|
||||||
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
|
||||||
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
|
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
|
||||||
|
|
||||||
|
const manifestInput = require('./src/manifest');
|
||||||
|
|
||||||
const targetBrowser = process.env.TARGET_BROWSER;
|
const targetBrowser = process.env.TARGET_BROWSER;
|
||||||
|
const manifest = wextManifest[targetBrowser](manifestInput);
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
@ -35,26 +40,6 @@ module.exports = {
|
|||||||
cleanStaleWebpackAssets: false,
|
cleanStaleWebpackAssets: false,
|
||||||
verbose: true,
|
verbose: true,
|
||||||
}),
|
}),
|
||||||
new CopyWebpackPlugin([
|
|
||||||
{ from: 'src/assets', to: 'assets' },
|
|
||||||
{
|
|
||||||
from: `src/manifests/${targetBrowser}.json`,
|
|
||||||
transform(content, path) {
|
|
||||||
// generates the manifest file using the package.json informations
|
|
||||||
return Buffer.from(
|
|
||||||
JSON.stringify({
|
|
||||||
version: process.env.npm_package_version,
|
|
||||||
background: {
|
|
||||||
persistent: false,
|
|
||||||
scripts: ['js/background.bundle.js'],
|
|
||||||
},
|
|
||||||
...JSON.parse(content.toString()),
|
|
||||||
})
|
|
||||||
);
|
|
||||||
},
|
|
||||||
to: 'manifest.json',
|
|
||||||
},
|
|
||||||
]),
|
|
||||||
new HtmlWebpackPlugin({
|
new HtmlWebpackPlugin({
|
||||||
template: 'src/options.html',
|
template: 'src/options.html',
|
||||||
// inject: false,
|
// inject: false,
|
||||||
@ -67,6 +52,8 @@ module.exports = {
|
|||||||
chunks: ['popup'],
|
chunks: ['popup'],
|
||||||
filename: 'popup.html',
|
filename: 'popup.html',
|
||||||
}),
|
}),
|
||||||
|
new CopyWebpackPlugin([{ from: 'src/assets', to: 'assets' }]),
|
||||||
|
new WriteWebpackPlugin([{ name: manifest.name, data: Buffer.from(manifest.content) }]),
|
||||||
],
|
],
|
||||||
|
|
||||||
module: {
|
module: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user