Split runtime info

This commit is contained in:
the1812 2022-06-09 09:06:29 +08:00
parent ad05621ee9
commit 00189a11b7
4 changed files with 17 additions and 12 deletions

View File

@ -1,12 +1,8 @@
const commonMeta = require('../../src/client/common.meta.json') const runtimeInfo = require('./runtime')
const { altCdn } = require('../cdn')
const compilationInfo = { const compilationInfo = {
year: new Date().getFullYear(), ...runtimeInfo,
version: commonMeta.version, ...webpackGitInfo,
altCdn,
...(typeof webpackGitInfo === 'object' ? webpackGitInfo : {}),
// buildTime: Number(new Date()),
} }
module.exports = { module.exports = {
compilationInfo, compilationInfo,

View File

@ -0,0 +1,8 @@
const commonMeta = require('../../src/client/common.meta.json')
const { altCdn } = require('../cdn')
module.exports = {
year: new Date().getFullYear(),
version: commonMeta.version,
altCdn,
}

View File

@ -1,4 +1,5 @@
const { compilationInfo } = require('../compilation-info') const runtimeInfo = require('../compilation-info/runtime')
const gitInfo = require('../compilation-info/git')
const nodePath = require('path') const nodePath = require('path')
module.exports = function (babel) { module.exports = function (babel) {
@ -22,8 +23,8 @@ module.exports = function (babel) {
return return
} }
targetExpression.properties.push(...[ targetExpression.properties.push(...[
types.objectProperty(types.identifier('commitHash'), types.stringLiteral(compilationInfo.commitHash)), types.objectProperty(types.identifier('commitHash'), types.stringLiteral(gitInfo.commitHash)),
types.objectProperty(types.identifier('coreVersion'), types.stringLiteral(compilationInfo.version)), types.objectProperty(types.identifier('coreVersion'), types.stringLiteral(runtimeInfo.version)),
]) ])
}) })
} }

View File

@ -7,7 +7,7 @@ const {
cssStyleLoaders, sassStyleLoaders cssStyleLoaders, sassStyleLoaders
} = require('./loaders/style-loaders') } = require('./loaders/style-loaders')
const tsLoader = require('./loaders/ts-loader') const tsLoader = require('./loaders/ts-loader')
const { compilationInfo } = require('./compilation-info') const runtimeInfo = require('./compilation-info/runtime')
const relativePath = p => path.join(process.cwd(), p) const relativePath = p => path.join(process.cwd(), p)
const getDefaultConfig = (srcFolder) => { const getDefaultConfig = (srcFolder) => {
@ -156,7 +156,7 @@ const commonMeta = require('../src/client/common.meta.json')
const replaceVariables = text => { const replaceVariables = text => {
return text.replace(/\[([^\[\]]+)\]/g, match => { return text.replace(/\[([^\[\]]+)\]/g, match => {
const value = get(compilationInfo, match) const value = get(runtimeInfo, match)
if (value !== undefined) { if (value !== undefined) {
return value return value
} }