about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAkihiko Odaki <akihiko.odaki.4i@stu.hosei.ac.jp>2017-05-10 02:51:45 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-05-09 19:51:45 +0200
commitaf6a84da147f4230807b37c64bc09760e6ab5055 (patch)
treee1b95651cbf51c8dbb3009079220fe515ea7c8cd
parent08e94d1b197a053504ce37dbbe03216a80043b10 (diff)
Use RegExp for require.context to filter custom stylesheets (#2950)
ExtractTextWebpackPlugin extracts the content of loaded files, which means
it loads files loaded by require.context but not required after that.
However the former implementation is not aware of that.

require.context can have a RegExp to filter files to load. This change
gives a RegExp which matches with SCSSes with 'custom' prefix to
require.context to take advantage of the feature.
-rw-r--r--app/javascript/packs/application.js7
1 files changed, 1 insertions, 6 deletions
diff --git a/app/javascript/packs/application.js b/app/javascript/packs/application.js
index 247ac3922..367b7e76a 100644
--- a/app/javascript/packs/application.js
+++ b/app/javascript/packs/application.js
@@ -15,12 +15,7 @@ window.Perf = require('react-addons-perf');
 Rails.start();
 
 require.context('../images/', true);
-
-const customContext = require.context('../../assets/stylesheets/', false);
-
-if (customContext.keys().indexOf('./custom.scss') !== -1) {
-  customContext('./custom.scss');
-}
+require.context('../../assets/stylesheets/', false, /custom.*\.scss$/);
 
 document.addEventListener('DOMContentLoaded', () => {
   const mountNode = document.getElementById('mastodon');