Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assetsSources (alternative source path for rnv app assets) #1005

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 27 additions & 7 deletions packages/rnv/src/core/projectManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,33 @@ export const copyAssetsFolder = async (c, platform, subPath, customFn) => {

if (!isPlatformActive(c, platform)) return;


const tsPathsConfig = getTimestampPathsConfig(c, platform);

const assetSources = getConfigProp(c, c.platform, 'assetSources', []);

const validAssetSources = [];
assetSources.forEach(v => {
const assetsPath = path.join(_resolvePackage(c, v), platform);
if (fsExistsSync(assetsPath)) {
validAssetSources.push(assetsPath);
}
});

const destPath = path.join(
getPlatformProjectDir(c, platform),
subPath || ''
);

// FOLDER MERGERS FROM EXTERNAL SOURCES
if (validAssetSources.length > 0) {
logInfo(`Found custom assetSources at ${chalk().white(validAssetSources.join('/n'))}. Will be used to generate assets.`);
validAssetSources.forEach((sourcePath) => {
copyFolderContentsRecursiveSync(sourcePath, destPath, true, false, false, {}, tsPathsConfig, c);
});
return;
}

// FOLDER MERGERS FROM APP CONFIG + EXTEND
if (c.paths.appConfig.dirs) {
const hasAssetFolder = c.paths.appConfig.dirs
Expand Down Expand Up @@ -495,13 +522,6 @@ export const copyAssetsFolder = async (c, platform, subPath, customFn) => {
return customFn(c, platform);
}

const destPath = path.join(
getPlatformProjectDir(c, platform),
subPath || ''
);

const tsPathsConfig = getTimestampPathsConfig(c, platform);

// FOLDER MERGERS FROM APP CONFIG + EXTEND
if (c.paths.appConfig.dirs) {
c.paths.appConfig.dirs.forEach((v) => {
Expand Down
14 changes: 14 additions & 0 deletions packages/rnv/src/core/schemaManager/schemaRenativeJson.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,20 @@ const commonProps = {
'If set to `true` generated js (bundle.js) files will be timestamped and named (bundle-1.0.0.js) every new version. This is useful if you want to enforce invalidate cache agains standard CDN cache policies every new version you deploy',
examples: [true, false],
},
fontSources: {
type: 'array',
items: { type: 'string' },
description:
'Array of paths to location of external Fonts',
examples: [['{{resolvePackage(react-native-vector-icons)}}/Fonts']],
},
assetsSources: {
type: 'array',
items: { type: 'string' },
description:
'Array of paths to alternative external assets. this will take priority over ./appConfigs/base/assets folder on your local project',
examples: [['{{resolvePackage(@flexn/template-starter)}}/appConfigs/base/assets']],
},
...propExt,
};

Expand Down