diff options
author | Akihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp> | 2017-05-16 03:20:10 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-15 20:20:10 +0200 |
commit | 85c9496340668ad2ebd04eea57d669f82b7dbaf1 (patch) | |
tree | e8c8ec78c00b56af36de0aec70221f4b9f323597 /app | |
parent | 6ee3a10f1732c6f7fd22a051c78868bf88fecdac (diff) |
Introduce common JavaScript file (#2981)
* Create common chunk rather than vendor chunk vendor chunk is a set of modules provided by external vendors, but now we can have a chunk as a set of modules shared by multiple entry points, which could be more efficent than having vendor chunk. * Start rails-ujs in common.js This is used by /settings/two_factor_authentication.
Diffstat (limited to 'app')
-rw-r--r-- | app/javascript/mastodon/main.js | 3 | ||||
-rw-r--r-- | app/javascript/packs/common.js | 2 | ||||
-rw-r--r-- | app/javascript/packs/public.js | 3 | ||||
-rwxr-xr-x | app/views/layouts/application.html.haml | 3 |
4 files changed, 3 insertions, 8 deletions
diff --git a/app/javascript/mastodon/main.js b/app/javascript/mastodon/main.js index 08845112b..313721c88 100644 --- a/app/javascript/mastodon/main.js +++ b/app/javascript/mastodon/main.js @@ -17,11 +17,8 @@ function main() { const Mastodon = require('mastodon/containers/mastodon').default; const React = require('react'); const ReactDOM = require('react-dom'); - const Rails = require('rails-ujs'); window.Perf = require('react-addons-perf'); - Rails.start(); - require.context('../images/', true); // import customization styles diff --git a/app/javascript/packs/common.js b/app/javascript/packs/common.js new file mode 100644 index 000000000..9d63d8f98 --- /dev/null +++ b/app/javascript/packs/common.js @@ -0,0 +1,2 @@ +import { start } from 'rails-ujs'; +start(); diff --git a/app/javascript/packs/public.js b/app/javascript/packs/public.js index bbeb0a9ec..6aef2ffee 100644 --- a/app/javascript/packs/public.js +++ b/app/javascript/packs/public.js @@ -3,12 +3,9 @@ import { length } from 'stringz'; import { default as dateFormat } from 'date-fns/format'; import distanceInWordsStrict from 'date-fns/distance_in_words_strict'; import { delegate } from 'rails-ujs'; -import Rails from 'rails-ujs'; require.context('../images/', true); -Rails.start(); - const parseFormat = (format) => format.replace(/%(\w)/g, (_, modifier) => { switch (modifier) { case '%': diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 73fab9a5c..21590ae3c 100755 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -18,9 +18,8 @@ = ' - ' = title - = stylesheet_pack_tag 'vendor', media: 'all' = stylesheet_pack_tag 'application', media: 'all' - = javascript_pack_tag 'vendor', integrity: true, crossorigin: 'anonymous' + = javascript_pack_tag 'common', integrity: true, crossorigin: 'anonymous' = csrf_meta_tags = yield :header_tags |