mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-21 05:52:41 +08:00
Implement i18n messages extractor. Contrary to @angular/complier-cli's command it will not throw an error if a resource is not found.
40 lines
1.0 KiB
TypeScript
40 lines
1.0 KiB
TypeScript
import * as path from 'path';
|
|
|
|
import {CliConfig} from './config';
|
|
import {NgCliWebpackConfig} from './webpack-config';
|
|
const webpackMerge = require('webpack-merge');
|
|
import {getWebpackExtractI18nConfig} from './webpack-configs';
|
|
|
|
export interface XI18WebpackOptions {
|
|
genDir?: string;
|
|
buildDir?: string;
|
|
i18nFormat?: string;
|
|
verbose?: boolean;
|
|
progress?: boolean;
|
|
}
|
|
export class XI18nWebpackConfig extends NgCliWebpackConfig {
|
|
|
|
public config: any;
|
|
|
|
constructor(extractOptions: XI18WebpackOptions) {
|
|
|
|
super({
|
|
target: 'development',
|
|
verbose: extractOptions.verbose,
|
|
progress: extractOptions.progress
|
|
});
|
|
|
|
const configPath = CliConfig.configFilePath();
|
|
const projectRoot = path.dirname(configPath);
|
|
const appConfig = CliConfig.fromProject().config.apps[0];
|
|
|
|
const extractI18nConfig =
|
|
getWebpackExtractI18nConfig(projectRoot,
|
|
appConfig,
|
|
extractOptions.genDir,
|
|
extractOptions.i18nFormat);
|
|
|
|
this.config = webpackMerge([this.config, extractI18nConfig]);
|
|
}
|
|
}
|