Switch to using a common
runtime chunk rather than locales
This commit is contained in:
parent
8c26d49cbd
commit
34efd1a24c
|
@ -1,22 +0,0 @@
|
||||||
let theLocale;
|
|
||||||
|
|
||||||
export function setLocale(locale) {
|
|
||||||
theLocale = locale;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getLocale() {
|
|
||||||
return theLocale;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function onProviderError(error) {
|
|
||||||
// Silent the error, like upstream does
|
|
||||||
if(process.env.NODE_ENV === 'production') return;
|
|
||||||
|
|
||||||
// This browser does not advertise Intl support for this locale, we only print a warning
|
|
||||||
// As-per the spec, the browser should select the best matching locale
|
|
||||||
if(typeof error === "object" && error.message.match("MISSING_DATA")) {
|
|
||||||
console.warn(error.message);
|
|
||||||
}
|
|
||||||
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
%title= content_for?(:page_title) ? safe_join([yield(:page_title).chomp.html_safe, title], ' - ') : title
|
%title= content_for?(:page_title) ? safe_join([yield(:page_title).chomp.html_safe, title], ' - ') : title
|
||||||
|
|
||||||
= javascript_pack_tag "locales", crossorigin: 'anonymous'
|
= javascript_pack_tag "common", crossorigin: 'anonymous'
|
||||||
- if @theme
|
- if @theme
|
||||||
- if @theme[:supported_locales].include? I18n.locale.to_s
|
- if @theme[:supported_locales].include? I18n.locale.to_s
|
||||||
= preload_pack_asset "locales/#{@theme[:flavour]}/#{I18n.locale}-json.js"
|
= preload_pack_asset "locales/#{@theme[:flavour]}/#{I18n.locale}-json.js"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
%link{ rel: 'dns-prefetch', href: storage_host }/
|
%link{ rel: 'dns-prefetch', href: storage_host }/
|
||||||
|
|
||||||
= render_initial_state
|
= render_initial_state
|
||||||
= javascript_pack_tag 'locales', crossorigin: 'anonymous'
|
= javascript_pack_tag 'common', crossorigin: 'anonymous'
|
||||||
- if @theme
|
- if @theme
|
||||||
- if @theme[:supported_locales].include? I18n.locale.to_s
|
- if @theme[:supported_locales].include? I18n.locale.to_s
|
||||||
= preload_pack_asset "locales/#{@theme[:flavour]}/#{I18n.locale}-json.js"
|
= preload_pack_asset "locales/#{@theme[:flavour]}/#{I18n.locale}-json.js"
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
%meta{ charset: 'utf-8' }/
|
%meta{ charset: 'utf-8' }/
|
||||||
%title= safe_join([yield(:page_title), Setting.default_settings['site_title']], ' - ')
|
%title= safe_join([yield(:page_title), Setting.default_settings['site_title']], ' - ')
|
||||||
%meta{ content: 'width=device-width,initial-scale=1', name: 'viewport' }/
|
%meta{ content: 'width=device-width,initial-scale=1', name: 'viewport' }/
|
||||||
= javascript_pack_tag "locales", crossorigin: 'anonymous'
|
= javascript_pack_tag "common", crossorigin: 'anonymous'
|
||||||
= render partial: 'layouts/theme', object: (@core || { pack: 'common' })
|
= render partial: 'layouts/theme', object: (@core || { pack: 'common' })
|
||||||
= render partial: 'layouts/theme', object: (@theme || { pack: 'error', flavour: 'glitch', common: { pack: 'common', flavour: 'glitch', skin: 'default' } })
|
= render partial: 'layouts/theme', object: (@theme || { pack: 'error', flavour: 'glitch', common: { pack: 'common', flavour: 'glitch', skin: 'default' } })
|
||||||
%body.error
|
%body.error
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
- content_for :header_tags do
|
- content_for :header_tags do
|
||||||
= render_initial_state
|
= render_initial_state
|
||||||
= javascript_pack_tag 'locales', crossorigin: 'anonymous'
|
= javascript_pack_tag 'common', crossorigin: 'anonymous'
|
||||||
- if @theme
|
- if @theme
|
||||||
- if @theme[:supported_locales].include? I18n.locale.to_s
|
- if @theme[:supported_locales].include? I18n.locale.to_s
|
||||||
= preload_pack_asset "locales/#{@theme[:flavour]}/#{I18n.locale}-json.js"
|
= preload_pack_asset "locales/#{@theme[:flavour]}/#{I18n.locale}-json.js"
|
||||||
|
|
|
@ -47,7 +47,6 @@ function reducePacks (data, into = {}) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const entries = Object.assign(
|
const entries = Object.assign(
|
||||||
{ locales: resolve('app', 'javascript', 'locales') },
|
|
||||||
reducePacks(core),
|
reducePacks(core),
|
||||||
Object.values(flavours).reduce((map, data) => reducePacks(data, map), {}),
|
Object.values(flavours).reduce((map, data) => reducePacks(data, map), {}),
|
||||||
);
|
);
|
||||||
|
@ -67,7 +66,7 @@ module.exports = {
|
||||||
|
|
||||||
optimization: {
|
optimization: {
|
||||||
runtimeChunk: {
|
runtimeChunk: {
|
||||||
name: 'locales',
|
name: 'common',
|
||||||
},
|
},
|
||||||
splitChunks: {
|
splitChunks: {
|
||||||
cacheGroups: {
|
cacheGroups: {
|
||||||
|
|
Loading…
Reference in a new issue