mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-12 03:01:16 +00:00
33 lines
960 B
JavaScript
33 lines
960 B
JavaScript
const { execSync } = require('child_process');
|
|
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
|
|
|
|
function getReleaseVersion() {
|
|
const gitBranchName = execSync('git rev-parse --abbrev-ref HEAD', { encoding: 'utf-8' });
|
|
const reBranchVersion = /^(?:[\w-]+\/)(\d+\.\d+\.\d+)$/im;
|
|
const match = reBranchVersion.exec(gitBranchName);
|
|
if (!match) {
|
|
throw new Error(`[engine] gitBranchName: ${gitBranchName} is not valid`);
|
|
}
|
|
|
|
return match[1];
|
|
}
|
|
|
|
const version = getReleaseVersion();
|
|
|
|
module.exports = ({ context, onGetWebpackConfig }) => {
|
|
onGetWebpackConfig((config) => {
|
|
config.resolve
|
|
.plugin('tsconfigpaths')
|
|
.use(TsconfigPathsPlugin, [{
|
|
configFile: './tsconfig.json',
|
|
}]);
|
|
config
|
|
.plugin('define')
|
|
.use(context.webpack.DefinePlugin, [{
|
|
VERSION_PLACEHOLDER: JSON.stringify(version),
|
|
}]);
|
|
config.plugins.delete('hot');
|
|
config.devServer.hot(false);
|
|
});
|
|
};
|