mirror of
https://github.com/openharmony/developtools_ace-js2bundle.git
synced 2026-07-22 14:45:28 -04:00
@@ -20,6 +20,7 @@ const md5 = require('md5');
|
||||
|
||||
const red = '\u001b[31m';
|
||||
const reset = '\u001b[39m';
|
||||
const multiResourceBuild = {};
|
||||
|
||||
function deleteFolderRecursive(url) {
|
||||
let files = [];
|
||||
@@ -140,10 +141,24 @@ function hashProjectPath(projectPath) {
|
||||
process.env.hashProjectPath = "_" + md5(projectPath);
|
||||
}
|
||||
|
||||
function checkMultiResourceBuild(aceBuildJson) {
|
||||
if (aceBuildJson && fs.existsSync(aceBuildJson)) {
|
||||
try {
|
||||
const content = JSON.parse(fs.readFileSync(aceBuildJson));
|
||||
if (content["multiResourceBuild"]) {
|
||||
multiResourceBuild.value = content["multiResourceBuild"]
|
||||
}
|
||||
} catch (error) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
deleteFolderRecursive: deleteFolderRecursive,
|
||||
readManifest: readManifest,
|
||||
loadEntryObj: loadEntryObj,
|
||||
compileCardModule: compileCardModule,
|
||||
hashProjectPath: hashProjectPath
|
||||
hashProjectPath: hashProjectPath,
|
||||
checkMultiResourceBuild: checkMultiResourceBuild,
|
||||
multiResourceBuild: multiResourceBuild
|
||||
};
|
||||
@@ -20,6 +20,7 @@ const SingleEntryPlugin = require('webpack/lib/SingleEntryPlugin');
|
||||
const CUSTOM_THEME_PROP_GROUPS = require('./theme/customThemeStyles');
|
||||
const OHOS_THEME_PROP_GROUPS = require('./theme/ohosStyles');
|
||||
import { mkDir } from './util';
|
||||
import { multiResourceBuild } from '../main.product';
|
||||
|
||||
const FILE_EXT_NAME = ['.js', '.css', '.jsx', '.less', '.sass', '.scss', '.md', '.DS_Store', '.hml', '.json'];
|
||||
const red = '\u001b[31m';
|
||||
@@ -123,7 +124,16 @@ class ResourcePlugin {
|
||||
}
|
||||
apply(compiler) {
|
||||
compiler.hooks.beforeCompile.tap('resource Copy', () => {
|
||||
circularFile(input, output, '');
|
||||
if (multiResourceBuild.value) {
|
||||
const res = multiResourceBuild.value.res;
|
||||
if (res) {
|
||||
res.forEach(item => {
|
||||
circularFile(path.resolve(input, item), path.resolve(output, item), '');
|
||||
})
|
||||
}
|
||||
} else {
|
||||
circularFile(input, output, '');
|
||||
}
|
||||
circularFile(input, output, '../share');
|
||||
});
|
||||
compiler.hooks.normalModuleFactory.tap('OtherEntryOptionPlugin', () => {
|
||||
@@ -153,7 +163,6 @@ class ResourcePlugin {
|
||||
}
|
||||
writeCSSInfo(watchCSSFiles, cssFiles);
|
||||
}
|
||||
|
||||
});
|
||||
compiler.hooks.done.tap('copyManifest', () => {
|
||||
copyManifest();
|
||||
@@ -173,8 +182,13 @@ let entryObj = {};
|
||||
function addPageEntryObj() {
|
||||
entryObj = {};
|
||||
if (process.env.abilityType === 'page') {
|
||||
const jsonString = readManifest(manifestFilePath);
|
||||
const pages = jsonString.pages;
|
||||
let jsonContent;
|
||||
if (multiResourceBuild.value) {
|
||||
jsonContent = multiResourceBuild.value;
|
||||
} else {
|
||||
jsonContent = readManifest(manifestFilePath);
|
||||
}
|
||||
const pages = jsonContent.pages;
|
||||
if (pages === undefined) {
|
||||
throw Error('ERROR: missing pages').message;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,8 @@ const {
|
||||
readManifest,
|
||||
loadEntryObj,
|
||||
compileCardModule,
|
||||
hashProjectPath
|
||||
hashProjectPath,
|
||||
checkMultiResourceBuild
|
||||
} = require('./main.product')
|
||||
|
||||
const richModule = {
|
||||
@@ -195,6 +196,8 @@ function setConfigs(env) {
|
||||
process.env.PLATFORM_VERSION = PLATFORM.VERSION3;
|
||||
}
|
||||
}
|
||||
process.env.aceBuildJson = env.aceBuildJson || process.env.aceBuildJson;
|
||||
checkMultiResourceBuild(process.env.aceBuildJson);
|
||||
}
|
||||
|
||||
function notPreview(env) {
|
||||
|
||||
Reference in New Issue
Block a user