Skip to content

Commit

Permalink
fix(build): honor tsconfig compilerOptions.rootDir to copy resources
Browse files Browse the repository at this point in the history
For example:

src/__tests__/fixtures/my.conf -> dist/__tests__/fixtures/my.conf
  • Loading branch information
raymondfeng committed May 10, 2019
1 parent 12a3ecb commit 8a8857d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/build/bin/compile-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,23 @@ function run(argv, options) {
? tsConfig.include.join('|')
: ['src', 'test'].join('|');

const compilerRootDir =
(tsConfig.compilerOptions && tsConfig.compilerOptions.rootDir) || '';

const pattern = `@(${dirs})/**/!(*.ts)`;
const files = glob.sync(pattern, {root: packageDir, nodir: true});
for (const file of files) {
fse.copySync(path.join(packageDir, file), path.join(outDir, file));
/**
* Trim path that matches tsConfig.compilerOptions.rootDir
*/
let targetFile = file;
if (compilerRootDir && file.startsWith(compilerRootDir + '/')) {
targetFile = file.substring(compilerRootDir.length + 1);
}
fse.copySync(
path.join(packageDir, file),
path.join(outDir, targetFile),
);
}
}
}
Expand Down

0 comments on commit 8a8857d

Please sign in to comment.