1
ビルド中に環境変数の値にアクセスして、文字列を置き換える方法を教えてください。ビルド中に環境変数にアクセスする方法
例:
aurelia_project /環境/ dev.ts
export default {
debug: true,
testing: true,
pageBaseUrl: 'https://localhost:9000' // <-- This is the info I'd like to fetch
};
aurelia_project /環境/ prod.ts
export default {
debug: true,
testing: true,
pageBaseUrl: 'https://www.foobar.com' // <-- This is the info I'd like to fetch
};
index.htmlを
<!DOCTYPE html>
<html>
<head>
<!-- ... -->
<base href="{pageBasePath}">
<!-- ... -->
</head>
<!-- ... -->
</html>
aurelia_project /タスク/ processIndex.ts
// ...
export default function processIndex() {
const pageBasePath = CLI.getEnvParamValue('pageBasePath');
return gulp.src('index.html')
.pipe(replace('{pageBasePath}', pageBasePath))
.pipe(gulp.dest(project.platform.outputIndex));
}
があり、いくつかのprocessIndex.ts
に同等の私の架空のCLI.getEnvParamValue('pageBasePath');
に組み込みまたは私は手動でaurelia_project/environments
内の適切なファイルからそれらに関する情報を読み取るために持っています(CLIOptions.getEnvironment()
を使用して)?
私は、環境をgulpビルドタスクにインポートすることに失敗したことを知っていました。おい、これは私を救った...あなたがコードを考え出してうれしい! – chdev77