Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

cannot load css on demand in one single entry #73

Closed
edwardfxiao opened this issue Jul 2, 2016 · 1 comment
Closed

cannot load css on demand in one single entry #73

edwardfxiao opened this issue Jul 2, 2016 · 1 comment

Comments

@edwardfxiao
Copy link

edwardfxiao commented Jul 2, 2016

for maintaining purpose, I have merged several entries into one single entry, and I am using require.ensure([], function(require) {}) to include my js and css file on demand, which looks like:

// common.js
if($('#is_a_page').length) {
 require.ensure(['a.js', 'a.css'], function(require) {
      require('a.js');
      require('a.css');
    });
}
else if($('#is_b_page').length) {
 require.ensure(['b.js', 'b.css'], function(require) {
      require('b.js');
      require('b.css');
    });
}


// a.js
alert('its page A');

// b.js
alert("its page B");
/*a.css*/
body{
  backgroung: #fff;
}

/*b.css*/
body{
  backgroung: #000!important;
}

then on both of page A and page B, I require the common.js and common.css

now, when I visit page A, it alerts "its page A" as expect, and "its page B" alerts on page B as well,
everything is perfectly fine, HOWEVER, on both page A and page B, the body's background turns to #000, it seems "require.ensure" only works on separating JS file whereas there is no way to separate two css files. Is that correct? any suggestions?

@ecmadao
Copy link

ecmadao commented Jul 2, 2016

same here, any thoughts??

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants