1.1.4 • Published 3 years ago

amd-deploy v1.1.4

Weekly downloads
6
License
ISC
Repository
github
Last release
3 years ago

amd-deploy

功能

  • 支持模块合并,用两级 include/exclude,实现最好的合并规则
  • 支持资源替换,便于缓存控制

配置

{
    // baseUrl 指向的本地硬盘路径
    baseUrl: '',

    // amd paths
    paths: { },

    // amd packages
    packages: [ ]
}

替换资源

{
    // 资源 ID 替换,如 require('underscore')
    // resource.id 表示代码中写的字面量,即 underscore
    // absolute 表示硬盘中的文件路径,如 project/dep/underscore/1.0.0/src/underscore.js
    replaceRequireResource: function (resource, absolute) {
        return resource.id + Date.now();
    },

    // 替换 require.config 中的一些值,比如 src 转为 asset
    replaceRequireConfig: function (config) {
        if (config.baseUrl) {
            config.baseUrl = config.baseUrl.replace('url', 'asset');
        }
        return config;
    }
}

模块合并

{
    combine: {

        // 全局 include 配置,应用于所有模块
        // include 表示即使模块不依赖某些模块,也会合并进去,避免需要时发请求
        include: [
            'underscore'
        ],

        // 全局 exclude 配置,应用于所有模块
        // exclude 表示即使模块依赖某些模块,也不会合并进去,第三方库和业务 common 层通常会用到
        exclude: [
            'cobble',
            'cobble/**/*'
        ],

        // 模块默认按自己的依赖进行合并(不合并 build 个毛...)
        // 只有配置成 false 才表示不需要合并(给你不合并的权利)

        // 模块默认继承全局 include 和 exclude
        // 只有按如下配置才表示不需要继承
        // {
        //     moduleId: {
        //         inheritInclude: false,
        //         inheritExclude: false
        //     }
        // }

        // 每个模块可以单独配置自己的 include 和 exclude,且优先级比全局 include exclude 更高,即
        // 如果 combine.include 包含了一些模块,module.exclude 可以去掉
        // 如果 combine.exclude 排除了一些模块,module.include 可以加上

        // exclude 和 moduleId 支持模糊匹配(为了避免误杀,只当 * 存在时开启),规则请参考 glob
        modules: {
            moduleId: {
                include: [ ],
                exclude: [ ]
            }
        }
    }
}

合并插件资源

如果需要合并样式或模板,可自己写规则,如下

{
    fileReader: {

        styl: function (filePath) {

            return 'define("id", [], function () {'
                 +     'return style;'
                 + '})';
        }

    }
}

压缩成一行

语法树生成代码,默认会被格式化,如果输入的代码已经过 uglify 处理,可用 minify 参数保持压缩状态

{
    minify: true
}
1.1.4

3 years ago

1.1.3

7 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.31

9 years ago

1.0.30

9 years ago

1.0.29

10 years ago

1.0.28

10 years ago

1.0.27

10 years ago

1.0.26

10 years ago

1.0.25

10 years ago

1.0.24

10 years ago

1.0.23

10 years ago

1.0.22

10 years ago

1.0.21

10 years ago

1.0.20

10 years ago

1.0.19

10 years ago

1.0.18

10 years ago

1.0.17

10 years ago

1.0.16

10 years ago

1.0.15

10 years ago

1.0.14

10 years ago

1.0.13

10 years ago

1.0.12

10 years ago

1.0.11

10 years ago

1.0.10

10 years ago

1.0.9

10 years ago

1.0.8

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago