I am working with a chrome extension which uses webpack to build.
To build I use this : cross-env NODE_ENV=production yarn webpack -c webpack.config.js --mode production
webpack.config.js
const HTMLPlugin = require('html-webpack-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const path = require('path');
const UglifyJSPlugin = require('uglifyjs-webpack-plugin');
const BrowserExtensionPlugin = require("extension-build-webpack-plugin");
module.exports = {
entry: {
options: './src/options.tsx',
popup: './src/popup.tsx',
content: './src/content.tsx',
background: './src/background.tsx',
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'build'),
},
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.css'],
modules: [path.resolve(__dirname, 'src'), 'node_modules'],
alias: {
react: 'preact/compat',
'react-dom': 'preact/compat',
},
},
module: {
rules: [
{
test: /\.(tsx|jsx|ts|js)x?$/,
exclude: /node_modules/,
use: [
{
loader: 'babel-loader',
options: {
presets: [
"@babel/preset-env",
"@babel/preset-react",
"@babel/preset-typescript",
],
},
},
],
},
{
test: /\.svg$/,
use: ['@svgr/webpack'],
},
],
},
plugins: [
new HTMLPlugin({
chunks: ['options'],
filename: 'options.html',
title: 'Options page title',
}),
new HTMLPlugin({
chunks: ['popup'],
filename: 'popup.html',
}),
new CopyPlugin([
{ from: './src/_locales/', to: './_locales' },
{ from: './src/assets', to: './assets' },
{ from: './src/manifest.json', to: './manifest.json' },
]),
new BrowserExtensionPlugin({devMode: false, name: "build/chromium.zip", directory: "src", updateType: "minor"}),
],
optimization: {
minimizer: [
new UglifyJSPlugin({
uglifyOptions: {
compress: {
drop_console: true,
drop_debugger: true,
}
}
})
]
},
mode: 'production',
stats: 'minimal',
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000
}
};
manifest.json:
{
"manifest_version": 3,
"name": "__MSG_appName__",
"description": "__MSG_appDesc__",
"default_locale": "en",
"version": "0.1.0",
....
....
}
If I run cross-env NODE_ENV=production yarn webpack -c webpack.config.js --mode production
again it increments the version
from 0.1.0
to 0.2.0
automatically not just in build
folder but in src
folder as well. How can I prevent this auto increment functionality.
I suspect it's due to one of the webpack plugins I am using.
This is caused by extension-build-webpack-plugin
which you really shouldn't have struggled to find, as there's a total of 4 plugins there to look at.
No, it does not offer any method of avoiding version bumps. You can only configure if you want it to bump the major or minor version number, defaulting to minor.
It's a really weird library to be using, it gets few downloads and is unmaintained. There's probably better alternatives out there.