bem-site / bem-forum-content-ru

Content BEM forum for Russian speak users
MIT License
56 stars 6 forks source link

index.ie.css #642

Open tgsource opened 8 years ago

tgsource commented 8 years ago

Приветствую! Где должны располагаться стили и какое должно быть имя файла, чтобы собрался файл index.ie.css?

tadatuta commented 8 years ago

Если в качестве стартовой точки используется project-stub, то необходимо внести вот такие изменения в конфиг сборки (.enb/make.js):

diff --git a/.enb/make.js b/.enb/make.js
index a6afab6..1a45321 100644
--- a/.enb/make.js
+++ b/.enb/make.js
@@ -51,6 +51,14 @@ module.exports = function(config) {
                 }
             }],

+            [techs.stylus, {
+                target: '?.ie.css',
+                sourceSuffixes: ['styl', 'css', 'ie.styl', 'ie.css'],
+                autoprefixer: {
+                    browsers: ['ie >= 6']
+                }
+            }],
+
             // bemtree
             // [techs.bemtree, { devMode: process.env.BEMTREE_ENV === 'development' }],

@@ -90,9 +98,10 @@ module.exports = function(config) {

             // borschik
             [techs.borschik, { source: '?.js', target: '?.min.js', minify: isProd }],
-            [techs.borschik, { source: '?.css', target: '?.min.css', tech: 'cleancss', minify: isProd }]
+            [techs.borschik, { source: '?.css', target: '?.min.css', tech: 'cleancss', minify: isProd }],
+            [techs.borschik, { source: '?.ie.css', target: '?.min.ie.css', tech: 'cleancss', minify: isProd }]
         ]);

-        nodeConfig.addTargets([/* '?.bemtree.js', */ '?.html', '?.min.css', '?.min.js']);
+        nodeConfig.addTargets([/* '?.bemtree.js', */ '?.html', '?.min.css', '?.min.ie.css', '?.min.js']);
     });
 };

Подключить файл:

diff --git a/desktop.bundles/index/index.bemjson.js b/desktop.bundles/index/index.bemjson.js
index ade58bb..d906149 100644
--- a/desktop.bundles/index/index.bemjson.js
+++ b/desktop.bundles/index/index.bemjson.js
@@ -5,7 +5,12 @@ module.exports = {
     head : [
         { elem : 'meta', attrs : { name : 'description', content : '' } },
         { elem : 'meta', attrs : { name : 'viewport', content : 'width=device-width, initial-scale=1' } },
-        { elem : 'css', url : 'index.min.css' }
+        { elem : 'css', url : 'index.min.css' },
+        {
+            elem : 'conditional-comment',
+            condition : '<= IE 8', // стили для IE8 и ниже
+            content : { elem : 'css', url : 'index.min.ie.css' }
+        }
     ],
     scripts: [{ elem : 'js', url : 'index.min.js' }],
     mods : { theme : 'islands' },

И тогда блочные block-name.ie.styl (или block-name.ie.css) будут собираться в bundle-name.min.ie.css.