mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-22 00:36:34 +00:00
Fix translations in production builds (#5192)
* Fix translations in production builds * Make env functions
This commit is contained in:
parent
3c17ee03b6
commit
af6ebea4a3
@ -1,6 +1,14 @@
|
|||||||
module.exports = {
|
module.exports = {
|
||||||
isProdBuild: process.env.NODE_ENV === "production",
|
isProdBuild() {
|
||||||
isStatsBuild: process.env.STATS === "1",
|
return process.env.NODE_ENV === "production";
|
||||||
isTravis: process.env.TRAVIS === "true",
|
},
|
||||||
isNetlify: process.env.NETLIFY === "true",
|
isStatsBuild() {
|
||||||
|
return process.env.STATS === "1";
|
||||||
|
},
|
||||||
|
isTravis() {
|
||||||
|
return process.env.TRAVIS === "true";
|
||||||
|
},
|
||||||
|
isNetlify() {
|
||||||
|
return process.env.NETLIFY === "true";
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
@ -42,7 +42,7 @@ gulp.task(
|
|||||||
"copy-static",
|
"copy-static",
|
||||||
"webpack-prod-app",
|
"webpack-prod-app",
|
||||||
...// Don't compress running tests
|
...// Don't compress running tests
|
||||||
(envVars.isTravis ? [] : ["compress-app"]),
|
(envVars.isTravis() ? [] : ["compress-app"]),
|
||||||
gulp.parallel(
|
gulp.parallel(
|
||||||
"gen-pages-prod",
|
"gen-pages-prod",
|
||||||
"gen-index-app-prod",
|
"gen-index-app-prod",
|
||||||
|
@ -29,6 +29,6 @@ gulp.task(
|
|||||||
gulp.parallel("gen-icons-hassio", "gen-icons-mdi"),
|
gulp.parallel("gen-icons-hassio", "gen-icons-mdi"),
|
||||||
"webpack-prod-hassio",
|
"webpack-prod-hassio",
|
||||||
...// Don't compress running tests
|
...// Don't compress running tests
|
||||||
(envVars.isTravis ? [] : ["compress-hassio"])
|
(envVars.isTravis() ? [] : ["compress-hassio"])
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
@ -292,10 +292,11 @@ gulp.task(
|
|||||||
function fingerprintTranslationFiles() {
|
function fingerprintTranslationFiles() {
|
||||||
// Fingerprint full file of each language
|
// Fingerprint full file of each language
|
||||||
const files = fs.readdirSync(fullDir);
|
const files = fs.readdirSync(fullDir);
|
||||||
|
|
||||||
for (let i = 0; i < files.length; i++) {
|
for (let i = 0; i < files.length; i++) {
|
||||||
fingerprints[files[i].split(".")[0]] = {
|
fingerprints[files[i].split(".")[0]] = {
|
||||||
// In dev we create fake hashes
|
// In dev we create fake hashes
|
||||||
hash: env.isProdBuild
|
hash: env.isProdBuild()
|
||||||
? crypto
|
? crypto
|
||||||
.createHash("md5")
|
.createHash("md5")
|
||||||
.update(fs.readFileSync(path.join(fullDir, files[i]), "utf-8"))
|
.update(fs.readFileSync(path.join(fullDir, files[i]), "utf-8"))
|
||||||
@ -332,7 +333,7 @@ gulp.task(
|
|||||||
gulp.series(
|
gulp.series(
|
||||||
"clean-translations",
|
"clean-translations",
|
||||||
"ensure-translations-build-dir",
|
"ensure-translations-build-dir",
|
||||||
env.isProdBuild ? (done) => done() : "create-test-translation",
|
env.isProdBuild() ? (done) => done() : "create-test-translation",
|
||||||
"build-master-translation",
|
"build-master-translation",
|
||||||
"build-merged-translations",
|
"build-merged-translations",
|
||||||
gulp.parallel(...splitTasks),
|
gulp.parallel(...splitTasks),
|
||||||
|
@ -155,7 +155,7 @@ const createAppConfig = ({ isProdBuild, latestBuild, isStatsBuild }) => {
|
|||||||
`/static/translations/${englishFilename}`
|
`/static/translations/${englishFilename}`
|
||||||
] = `build-translations/output/${englishFilename}`;
|
] = `build-translations/output/${englishFilename}`;
|
||||||
|
|
||||||
Object.keys(translationMetadata.fragments).forEach((fragment) => {
|
translationMetadata.fragments.forEach((fragment) => {
|
||||||
workBoxTranslationsTemplatedURLs[
|
workBoxTranslationsTemplatedURLs[
|
||||||
`/static/translations/${fragment}/${englishFilename}`
|
`/static/translations/${fragment}/${englishFilename}`
|
||||||
] = `build-translations/output/${fragment}/${englishFilename}`;
|
] = `build-translations/output/${fragment}/${englishFilename}`;
|
||||||
|
@ -6,6 +6,6 @@ const { isProdBuild } = require("../build-scripts/env.js");
|
|||||||
const latestBuild = true;
|
const latestBuild = true;
|
||||||
|
|
||||||
module.exports = createCastConfig({
|
module.exports = createCastConfig({
|
||||||
isProdBuild,
|
isProdBuild: isProdBuild(),
|
||||||
latestBuild,
|
latestBuild,
|
||||||
});
|
});
|
||||||
|
@ -6,7 +6,7 @@ const { isProdBuild, isStatsBuild } = require("../build-scripts/env.js");
|
|||||||
const latestBuild = true;
|
const latestBuild = true;
|
||||||
|
|
||||||
module.exports = createDemoConfig({
|
module.exports = createDemoConfig({
|
||||||
isProdBuild,
|
isProdBuild: isProdBuild(),
|
||||||
isStatsBuild,
|
isStatsBuild: isStatsBuild(),
|
||||||
latestBuild,
|
latestBuild,
|
||||||
});
|
});
|
||||||
|
@ -6,6 +6,6 @@ const { isProdBuild } = require("../build-scripts/env.js");
|
|||||||
const latestBuild = false;
|
const latestBuild = false;
|
||||||
|
|
||||||
module.exports = createHassioConfig({
|
module.exports = createHassioConfig({
|
||||||
isProdBuild,
|
isProdBuild: isProdBuild(),
|
||||||
latestBuild,
|
latestBuild,
|
||||||
});
|
});
|
||||||
|
@ -5,8 +5,8 @@ const { isProdBuild, isStatsBuild } = require("./build-scripts/env.js");
|
|||||||
|
|
||||||
const configs = [
|
const configs = [
|
||||||
createAppConfig({
|
createAppConfig({
|
||||||
isProdBuild,
|
isProdBuild: isProdBuild(),
|
||||||
isStatsBuild,
|
isStatsBuild: isStatsBuild(),
|
||||||
latestBuild: true,
|
latestBuild: true,
|
||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
@ -14,8 +14,8 @@ const configs = [
|
|||||||
if (isProdBuild && !isStatsBuild) {
|
if (isProdBuild && !isStatsBuild) {
|
||||||
configs.push(
|
configs.push(
|
||||||
createAppConfig({
|
createAppConfig({
|
||||||
isProdBuild,
|
isProdBuild: isProdBuild(),
|
||||||
isStatsBuild,
|
isStatsBuild: isStatsBuild(),
|
||||||
latestBuild: false,
|
latestBuild: false,
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user