MORE FRONTENDS (EASY MODE) WIN!!!

This commit is contained in:
kibigo! 2017-06-22 20:15:11 -07:00
parent 101a4c6913
commit b3904c2553
7 changed files with 16 additions and 14 deletions

View File

@ -9,6 +9,7 @@ class HomeController < ApplicationController
@web_settings = Web::Setting.find_by(user: current_user)&.data || {}
@admin = Account.find_local(Setting.site_contact_username)
@streaming_api_base_url = Rails.configuration.x.streaming_api_base_url
@frontend = (params[:frontend] and Rails.root.join('app', 'javascript', 'packs', 'frontends', '#{params[:frontend]}.js')) ? params[:frontend] : 'mastodon'
end
private

View File

View File

@ -1,2 +1,3 @@
import { start } from 'rails-ujs';
require('../mastodon/locales');
start();

View File

@ -0,0 +1,6 @@
import main from '../../mastodon/main';
import loadPolyfills from '../../mastodon/load_polyfills';
loadPolyfills().then(main).catch(e => {
console.error(e);
});

View File

@ -1,7 +1,10 @@
- content_for :header_tags do
%script#initial-state{ type: 'application/json' }!= json_escape(render(file: 'home/initial_state', formats: :json))
= javascript_pack_tag 'application', integrity: true, crossorigin: 'anonymous'
= javascript_pack_tag "frontends/#{@frontend}", integrity: true, crossorigin: 'anonymous'
= stylesheet_pack_tag "frontends/#{@frontend}", integrity: true, media: 'all'
%script{ type: 'text/html' }!=@frontendp
.app-holder#mastodon{ data: { props: Oj.dump(default_props) } }
%noscript

View File

@ -18,11 +18,13 @@
= ' - '
= title
= stylesheet_pack_tag 'application', media: 'all'
= javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous'
= javascript_pack_tag "locale_#{I18n.locale}", integrity: true, crossorigin: 'anonymous'
= csrf_meta_tags
- if controller_name != 'home'
= stylesheet_pack_tag 'application', integrity: true, media: 'all'
= yield :header_tags
- body_classes ||= @body_classes

View File

@ -51,18 +51,7 @@ module.exports = {
}),
new webpack.optimize.CommonsChunkPlugin({
name: 'common',
minChunks: (module, count) => {
const reactIntlPathRegexp = new RegExp(`node_modules\\${sep}react-intl`);
if (module.resource && reactIntlPathRegexp.test(module.resource)) {
// skip react-intl because it's useless to put in the common chunk,
// e.g. because "shared" modules between zh-TW and zh-CN will never
// be loaded together
return false;
}
return count >= 2;
},
minChunks: Infinity
}),
],