File tree 2 files changed +28
-33
lines changed
2 files changed +28
-33
lines changed Original file line number Diff line number Diff line change
1
+ import * as path from 'path' ;
2
+
1
3
import { CliConfig } from './config' ;
2
4
import { NgCliWebpackConfig } from './webpack-config' ;
3
5
const webpackMerge = require ( 'webpack-merge' ) ;
4
6
import { getWebpackExtractI18nConfig } from './webpack-extract-i18n' ;
5
7
8
+ export interface XI18WebpackOptions {
9
+ genDir ?: string ,
10
+ buildDir ?: string ,
11
+ i18nFormat ?: string ,
12
+ verbose ?: boolean ,
13
+ progress ?: boolean
14
+ }
6
15
export class XI18nWebpackConfig extends NgCliWebpackConfig {
7
16
8
17
public config : any ;
9
18
10
- constructor (
11
- ngCliProject : any ,
12
- genDir : string ,
13
- buildDir : string ,
14
- i18nFormat : string ,
15
- verbose : boolean = false , progress : boolean = true ) {
16
- super (
17
- ngCliProject ,
18
- 'development' ,
19
- 'dev' ,
20
- buildDir ,
21
- null ,
22
- null ,
23
- null ,
24
- null ,
25
- false ,
26
- true ,
27
- true ,
28
- verbose ,
29
- progress ,
30
- null ,
31
- 'none' ,
32
- true ) ;
19
+ constructor ( extractOptions : XI18WebpackOptions ) {
20
+
21
+ super ( {
22
+ target : 'development' ,
23
+ verbose : extractOptions . verbose ,
24
+ progress : extractOptions . progress
25
+ } ) ;
33
26
27
+ const configPath = CliConfig . configFilePath ( ) ;
28
+ const projectRoot = path . dirname ( configPath ) ;
34
29
const appConfig = CliConfig . fromProject ( ) . config . apps [ 0 ] ;
35
30
36
- let config = this . config ;
37
31
const extractI18nConfig =
38
- getWebpackExtractI18nConfig ( this . ngCliProject . root , appConfig , genDir , i18nFormat ) ;
39
- config = webpackMerge ( config , extractI18nConfig ) ;
32
+ getWebpackExtractI18nConfig ( projectRoot ,
33
+ appConfig ,
34
+ extractOptions . genDir ,
35
+ extractOptions . i18nFormat ) ;
40
36
41
- this . config = config ;
37
+ this . config = webpackMerge ( [ this . config , extractI18nConfig ] ) ;
42
38
}
43
39
}
Original file line number Diff line number Diff line change @@ -18,14 +18,13 @@ export const Extracti18nTask = Task.extend({
18
18
const buildDir = '.tmp' ;
19
19
const genDir = runTaskOptions . outputPath || appConfig . root ;
20
20
21
- const config = new XI18nWebpackConfig (
22
- project ,
21
+ const config = new XI18nWebpackConfig ( {
23
22
genDir,
24
23
buildDir,
25
- runTaskOptions . i18nFormat ,
26
- runTaskOptions . verbose ,
27
- runTaskOptions . progress
28
- ) . config ;
24
+ i18nFormat : runTaskOptions . i18nFormat ,
25
+ verbose : runTaskOptions . verbose ,
26
+ progress : runTaskOptions . progress
27
+ } ) . config ;
29
28
30
29
const webpackCompiler = webpack ( config ) ;
31
30
//const statsConfig = getWebpackStatsConfig(runTaskOptions.verbose);
You can’t perform that action at this time.
0 commit comments