Skip to content

Commit fa94d39

Browse files
committed
Move file extension regexes to Constants.
1 parent 022862c commit fa94d39

2 files changed

Lines changed: 9 additions & 10 deletions

File tree

webpack/localization-plugin/src/WebpackConfigurationUpdater.ts

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ export class WebpackConfigurationUpdater {
7676
options.configuration,
7777
[
7878
{
79-
test: /\.loc\.json$/i,
79+
test: Constants.LOC_JSON_REGEX,
8080
loader: loader
8181
},
8282
{
83-
test: /\.resx$/i,
83+
test: Constants.RESX_REGEX,
8484
use: [
8585
require.resolve('json-loader'),
8686
{
@@ -134,7 +134,7 @@ export class WebpackConfigurationUpdater {
134134
test: {
135135
and: [
136136
(filePath: string) => options.locFiles.has(filePath),
137-
/\.loc\.json$/i
137+
Constants.LOC_JSON_REGEX
138138
]
139139
},
140140
loader: loader,
@@ -144,7 +144,7 @@ export class WebpackConfigurationUpdater {
144144
test: {
145145
and: [
146146
(filePath: string) => options.locFiles.has(filePath),
147-
/\.resx$/i
147+
Constants.RESX_REGEX
148148
]
149149
},
150150
use: [
@@ -172,12 +172,7 @@ export class WebpackConfigurationUpdater {
172172
and: [
173173
(filePath: string) => !options.locFiles.has(filePath),
174174
(filePath: string) => !options.filesToIgnore.has(filePath),
175-
{
176-
or: [
177-
/\.loc\.json$/i,
178-
/\.resx$/i
179-
]
180-
}
175+
Constants.RESX_OR_LOC_JSON_REGEX
181176
]
182177
},
183178
loader: path.resolve(__dirname, 'loaders', 'MissingLocDataWarningLoader.js')

webpack/localization-plugin/src/utilities/Constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,8 @@ export class Constants {
1616
'g'
1717
);
1818
public static STRING_PLACEHOLDER_PREFIX: string = '-LOCALIZED-STRING-f12dy0i7-n4bo-dqwj-39gf-sasqehjmihz9';
19+
20+
public static RESX_REGEX: RegExp = /\.resx$/i;
21+
public static LOC_JSON_REGEX: RegExp = /\.loc\.json$/i;
22+
public static RESX_OR_LOC_JSON_REGEX: RegExp = /\.(resx|loc\.json)$/i;
1923
}

0 commit comments

Comments
 (0)