关闭require.js第三方代码的uglification

时间:2013-11-19 23:34:51

标签: requirejs

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

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

我的项目中有一个文件夹,其中包含名为bower_components

的第三方依赖项

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

我怎样才能做到这一点?

1 个答案:

答案 0 :(得分:1)

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

    optimize: "none",

来自example.build.js docs:

    //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示例的链接。