1
0
mirror of https://gitlab.com/psono/psono-client synced 2025-04-19 03:22:16 +03:00
psono-client/webpack.environment.prod.webclient.js
Sascha Pfeiffer b6d1f72434 Switched to dynamic imports
Signed-off-by: Sascha Pfeiffer <sascha.pfeiffer@esaqa.com>
2025-02-02 19:25:02 +01:00

57 lines
1.6 KiB
JavaScript

const webpack = require('webpack');
const { merge } = require('webpack-merge');
const prodConfig = require('./webpack.environment.prod.common');
const webclient = require('./webpack.target.webclient');
const ReplaceInFileWebpackPlugin = require('replace-in-file-webpack-plugin');
const {InjectManifest} = require('workbox-webpack-plugin');
const commit_tag = process.env.CI_COMMIT_TAG;
const commit_sha = process.env.CI_COMMIT_SHA;
let version = '1.1.0';
let hash = 'abcd1234';
if (/^v\d*\.\d*\.\d*$/.test(commit_tag)) {
version = commit_tag.substring(1);
hash = commit_sha.substring(0,8);
}
module.exports = () => {
const config = merge(webclient, prodConfig);
config['plugins'].push(
new ReplaceInFileWebpackPlugin([{
dir: 'build/webclient',
files: ['VERSION.txt'],
rules: [{
search: '1.1.0',
replace: version
},{
search: 'abcd1234',
replace: hash
}]
}])
)
config['plugins'].push(
// Build the service worker
// should be last so all files are cached
new InjectManifest({
swSrc: './src/webclient/service-worker.js',
swDest: './service-worker.js',
exclude: [
/authenticate\.html/
],
modifyURLPrefix: {
'/': './',
'././': './',
},
compileSrc: true,
maximumFileSizeToCacheInBytes: 30000000,
webpackCompilationPlugins: [
new webpack.DefinePlugin({
'CACHE_VERSION': JSON.stringify(Date.now().toString())
})
]
}),
)
return config
};