Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

插件allinone 使css合并 link标签 rel 值不存在导致页面不能加载的bug #35

Open
noonhorse opened this issue Dec 7, 2015 · 6 comments

Comments

@noonhorse
Copy link

fis-conf.js 中的写法

    .match('::package', {
      spriter: fis.plugin('csssprites')
      ,postpackager: fis.plugin('loader', {
        useInlineMap: false // 资源映射表内嵌
        ,allInOne: 
        {
            js: 'js/${filepath}.js', // 打包后 css 的文件路径。
            css: 'css/${filepath}.css',
            ignore:['base/header.js'] 
        }
      })
    })

为执行loader allInOne的代码

    <link rel="stylesheet" type="text/css" href="/css/base/header.css" />
    <link rel="stylesheet" type="text/css" href="/css/a/a.css" />
    <link rel="stylesheet" type="text/css" href="/css/view/index.css" />

压缩后错误代码,缺少 rel="stylesheet"

<link rel="stylesheet" type="text/css" href="/css/base/header.css" />
<link type="text/css" href="/css/view/index.html_fb1c64e.css" />

修改方法将 插件
lib/lang/html.js 第284 行修改为如下代码

          // 只处理认识的 id
          if (item.id) {
            fis.emit('plugin:relative:fetch', msg);
          }
          //做判断是否有 stylesheet
          var stylesheetString ='';
          if(!/stylesheet/ig.test(item.attrs)) stylesheetString = ' rel="stylesheet"';
          css.push('<link' + item.attrs + stylesheetString + ' href="' + msg.ret + '" />');
        }
@2betop 2betop closed this as completed in 7d66544 Dec 7, 2015
@2betop
Copy link
Contributor

2betop commented Dec 7, 2015

读的是原始 attributes ,理论上应该不需要这么检测。

@2betop 2betop reopened this Dec 7, 2015
@2betop
Copy link
Contributor

2betop commented Dec 7, 2015

请尝试下这个修改,是否解决问题,麻烦:7d66544

@noonhorse
Copy link
Author

哥哥这个没用,我来给你分析一下。
错误显示缺少 rel="stylesheet" 说明attrs并不是空 或未定义
所以 attrs 是等于 type="text/css"
typeof attrs === 'undefined' 这个判断是 自然为false 的,
所以 attrs 还是 等于 type="text/css"
所以这个bug fix 并未解决问题
我知道要去根源上解决问题,但是确实没有跟踪到这个问题是哪里导致的

@2betop
Copy link
Contributor

2betop commented Dec 8, 2015

@noonhorse 你确定你试了?为何我这是好的?

before:

    <link rel="stylesheet" type="text/css" href="jquery-ui/themes/base/core.css" />
    <link rel="stylesheet" type="text/css" href="jquery-ui/themes/base/tabs.css" />
    <link rel="stylesheet" type="text/css" href="jquery-ui/themes/base/datepicker.css" />
    <link rel="stylesheet" type="text/css" href="jquery-ui/themes/base/theme.css" />
    <link rel="stylesheet" type="text/css" href="./style.css" />

after:

    <link rel="stylesheet" type="text/css" href="/pkg/index.html_aio.css" />

@2betop
Copy link
Contributor

2betop commented Dec 8, 2015

你说得对,那个修改确实是没用的,改的是内嵌 css 部分的 attributes, 但是,出现你这个情况的起因还没有分析出来。

@2betop
Copy link
Contributor

2betop commented Dec 8, 2015

问题定位到了,是 pack 的逻辑有问题,已经修复了,请更新 [email protected]

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

No branches or pull requests

2 participants