Skip to content

Commit 12cc8ed

Browse files
committed
Better support single locales and support serve.
1 parent 19e1823 commit 12cc8ed

9 files changed

Lines changed: 999 additions & 69 deletions

File tree

build-tests/localization-plugin-test/build.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const child_process = require('child_process');
33
const path = require('path');
44
const process = require('process');
55

6-
const { LocJsonPreprocessor } = require('@microsoft/localization-plugin');
6+
const { LocJsonPreprocessor } = require('@rushstack/localization-plugin');
77

88
function executeCommand(command) {
99
console.log('---> ' + command);

build-tests/localization-plugin-test/package.json

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,16 @@
44
"version": "0.1.0",
55
"private": true,
66
"scripts": {
7-
"build": "node build.js"
7+
"build": "node build.js",
8+
"serve": "node serve.js"
89
},
910
"dependencies": {
10-
"webpack": "~4.31.0",
1111
"@rushstack/localization-plugin": "0.0.0",
1212
"fs-extra": "~7.0.1",
1313
"@microsoft/rush-stack-compiler-3.5": "0.4.2",
14+
"ts-loader": "6.0.0",
15+
"webpack": "~4.31.0",
1416
"webpack-cli": "~3.3.2",
15-
"ts-loader": "6.0.0"
17+
"webpack-dev-server": "~3.9.0"
1618
}
1719
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const fsx = require('fs-extra');
2+
const child_process = require('child_process');
3+
const path = require('path');
4+
const process = require('process');
5+
6+
const { LocJsonPreprocessor } = require('@rushstack/localization-plugin');
7+
8+
function executeCommand(command) {
9+
console.log('---> ' + command);
10+
child_process.execSync(command, { stdio: 'inherit' });
11+
}
12+
13+
// Clean the old build outputs
14+
console.log(`==> Starting build.js for ${path.basename(process.cwd())}`);
15+
fsx.emptyDirSync('dist');
16+
fsx.emptyDirSync('lib');
17+
fsx.emptyDirSync('temp');
18+
19+
LocJsonPreprocessor.preprocessLocJsonFiles({
20+
srcFolder: path.resolve(__dirname, 'src'),
21+
generatedTsFolder: path.resolve(__dirname, 'temp', 'loc-json-ts')
22+
});
23+
24+
// Run Webpack
25+
executeCommand('node node_modules/webpack-dev-server/bin/webpack-dev-server');

build-tests/localization-plugin-test/webpack.config.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
const path = require('path');
44
const webpack = require('webpack');
55

6-
const { LocalizationPlugin } = require('@microsoft/localization-plugin');
6+
const { LocalizationPlugin } = require('@rushstack/localization-plugin');
77

88
module.exports = function(env) {
99
const configuration = {
@@ -69,6 +69,9 @@ module.exports = function(env) {
6969
},
7070
defaultLocale: {
7171
usePassthroughLocale: true
72+
},
73+
serveLocale: {
74+
locale: 'en-us'
7275
}
7376
})
7477
]
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// DO NOT ADD COMMENTS IN THIS FILE. They will be lost when the Rush tool resaves it.
22
{
33
"$schema": "https://developer.microsoft.com/json-schemas/rush/v5/approved-packages.schema.json",
4-
"packages": []
4+
"packages": [
5+
]
56
}

common/config/rush/nonbrowser-approved-packages.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@
3838
"name": "@microsoft/gulp-core-build-serve",
3939
"allowedCategories": [ "libraries" ]
4040
},
41+
{
42+
"name": "webpack-dev-server",
43+
"allowedCategories": [ "tests" ]
44+
},
4145
{
4246
"name": "@microsoft/gulp-core-build-typescript",
4347
"allowedCategories": [ "libraries" ]
@@ -50,10 +54,6 @@
5054
"name": "@microsoft/load-themed-styles",
5155
"allowedCategories": [ "libraries", "tests" ]
5256
},
53-
{
54-
"name": "@rushstack/localization-plugin",
55-
"allowedCategories": [ "tests" ]
56-
},
5757
{
5858
"name": "@microsoft/node-core-library",
5959
"allowedCategories": [ "libraries", "tests" ]
@@ -170,6 +170,10 @@
170170
"name": "@rushstack/eslint-plugin",
171171
"allowedCategories": [ "libraries" ]
172172
},
173+
{
174+
"name": "@rushstack/localization-plugin",
175+
"allowedCategories": [ "tests" ]
176+
},
173177
{
174178
"name": "@typescript-eslint/eslint-plugin",
175179
"allowedCategories": [ "libraries" ]

0 commit comments

Comments
 (0)