【问题标题】:Turn off uglification for require.js third party code关闭 require.js 第三方代码的丑化
【发布时间】:2013-12-03 18:27:00
【问题描述】:

这是优化器的 require.js 配置。

({
      appDir: 'app/'
    , baseUrl: 'js'
    , mainConfigFile: 'app/js/main.js'
    , dir: 'build/'
    , modules: [{ name: 'main' }]
})

我的项目中有一个文件夹,其中包含名为 bower_components 的第三方依赖项

当我运行 require.js 优化器时,它会遍历这些第三方依赖项中的每个 .css 和 .js 文件并将它们丑化。问题是我已经在我的代码中引用了正确的 *.min.js 文件。这需要很长时间,我想排除整个文件夹形式的丑化,但是,我仍然想在适当的地方将第三方依赖项合并到一个文件中。

我怎样才能做到这一点?

【问题讨论】:

    标签: requirejs


    【解决方案1】:

    要关闭丑化代码,请将此行添加到您的 Javascript 构建配置文件中:

        optimize: "none",
    

    来自 example.build.js 文档:

        //How to optimize all the JS files in the build output directory.
        //Right now only the following values
        //are supported:
        //- "uglify": (default) uses UglifyJS to minify the code.
        //- "uglify2": in version 2.1.2+. Uses UglifyJS2.
        //- "closure": uses Google's Closure Compiler in simple optimization
        //mode to minify the code. Only available if running the optimizer using
        //Java.
        //- "closure.keepLines": Same as closure option, but keeps line returns
        //in the minified files.
        //- "none": no minification will be done.
        optimize: "uglify",
    

    这是all the build configuration options 示例的链接。

    【讨论】:

    • 这不会为我的所有代码禁用它吗?我只想为第三方依赖项禁用它。
    • 哦,是的,它会的,我猜我错过了那部分。你有seen this吗?或者this could help.
    猜你喜欢
    • 2022-11-26
    • 1970-01-01
    • 1970-01-01
    • 2013-04-28
    • 1970-01-01
    • 2016-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多