【问题标题】:Minifying bootstrap.js with connect-assetmanager causes syntax error. Why?使用 connect-assetmanager 缩小 bootstrap.js 会导致语法错误。为什么?
【发布时间】:2012-05-03 18:30:09
【问题描述】:

在 node.js/Express 应用中使用 connect-assetmanager。

这行得通:

  js: {
      dataType: 'javascript',
      path: __dirname + '/../public/javascript/',
      files: [//'jquery-1.7.1.js'
             'bootstrap.min.js'
      ],
      route: /\/static\/javascript\/script\.js/
  }

(注意使用已经最小化的boostrap.js版本,并注释掉jquery文件进行测试)。

这失败了:

  js: {
      dataType: 'javascript',
      path: __dirname + '/../public/javascript/',
      files: [//'jquery-1.7.1.js'
             'bootstrap.js'
      ],
      route: /\/static\/javascript\/script\.js/
  }

注意非最小化的bootstrap.js

故障在于浏览器 (Chrome)。在 bootstrap.js 的 connect-assetmanager 压缩部分的第 120 行有一个语法错误:

119 isActive=$parent.hasClass('open')
120 clearMenus()!isActive&&$parent.toggleClass('open')
  Uncaught SyntaxError: Unexpected identifier
121 return false}}

这是我第一次尝试使用 connect-assetmanager 之类的工具来缩小/合并静态文件。这种事情在 JS 缩小器中是典型的吗?我该怎么办?

怀疑我们是否需要在 prod 之外的客户端上真正调试 bootstrap.js,但如果 Javascript 损坏是典型的,我不想投资于 connect-assetmanager。

【问题讨论】:

    标签: node.js express twitter-bootstrap connect minify


    【解决方案1】:

    不确定这是否真的算作一个答案,但较新版本的 Bootstrap 解决了这个问题。

    【讨论】:

      【解决方案2】:

      您错过了有关引导程序缺少分号问题的整个讨论

      https://github.com/twitter/bootstrap/issues/3057

      【讨论】:

        猜你喜欢
        • 2015-08-02
        • 1970-01-01
        • 2012-05-14
        • 2011-04-21
        • 2010-12-09
        • 1970-01-01
        • 2021-03-12
        • 2015-05-15
        • 1970-01-01
        相关资源
        最近更新 更多