1.1.5 • Published 3 years ago

@iovx/iv-tool v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

iv-tool

npm

node deps tests builds builds2 coverage licenses PR's welcome

基础打包工具

  • 支持 typescript 工具库打包

配置

优先级 iv.config.js > iv.json > .ivrc

module.exports = function() {
  return {
     "tsFiles": "demo/**/*.ts",
      "dist": "./",
      "cwd": "demo",
      "compress": {
        "dist": false
      },
      "clean": [
        "demo/dist/es",
        "demo/dist/lib"
      ]
  }
}

cli

// 打包产出 dist | es | dist
iv build 
// 开启监控模式,实时打包
iv start 
// 启动开发服务器
iv server 
// 生成项目打包文件
iv build:page 

详细

/**
 * @typedef {{
 *   log(...args),
 *   warn(...args),
 *   info(...args),
 *   success(...args),
 *   error(...args),
 * }} Log
 * @typedef {{script:string, env:{NODE_ENV:string},log:Log, args:string[]}} IVOptions
 */
/**
 * @param {IVOptions} options
 * @return {{cwd: string, pageOptions: {root: string, inject: {cdnUrl: string, apiUrl: string, baseUrl: string, core: {router: string}, nav: {home: string, member: string, console: string, passport: string, explore: string, docs: string, poster: string}, domain: string, loginUrl: string, callback: string}, page: {name: string, title: string, filename: string}, useDll: boolean, dll: {name: string, entry: string[]}[], server: {port: number, proxy: {"/local": {target: string, pathRewrite: {"^/local": string}}}}}, deployOptions: {url: string}}}
 */
module.exports = (options) => {
  const { script, log, env } = options;
  const flag = env.NODE_ENV === 'production';
  const isDevMode = script === 'start';
  log.info('当前模式:', isDevMode ? '开发模式' : '生产模式');
  return {
    cwd: '.',
    pageOptions: {
      root: '.',
      inject: {
        cdnUrl: flag ? 'https://static.example.io/cdn' : '/local',
        apiUrl: flag ? 'https://api.example.io/api' : '//api.assure.com/api',
        baseUrl: flag ? 'https://api.example.io' : '//api.assure.com',
        core: {
          router: 'browser',
        },
        nav: {
          home: flag ? '//www.example.io/' : isDevMode ? '//member.assure.com' : '//member.assure.com',
          member: flag ? '//i.example.io/' : isDevMode ? '//member.assure.com' : '//member.assure.com',
          console: flag ? '//console.example.io/' : isDevMode ? '//console.assure.com' : '//console.assure.com',
          passport: flag ? '//passport.example.io/' : isDevMode ? '//passport.assure.com' : '//passport.assure.com',
          explore: flag ? '//explore.example.io/' : isDevMode ? '//explore.assure.com' : '//explore.assure.com',
          docs: flag ? '//docs.example.io/' : isDevMode ? '//docs.assure.com' : '//docs.assure.com',
          poster: flag ? '//wiki.example.io/' : '//i.assure.io/',
        },
        domain: flag ? 'example.io' : 'assure.com',
        loginUrl: flag ? 'https://passport.example.io/' : isDevMode ? '//passport.assure.com' : '//passport.assure.com',
        callback: flag ? 'http://www.example.io/' : 'http://www.assure.com/',
      },
      page: {
        name: 'index',
        title: '微风文件管理中心',
        filename: 'index.html',
      },
      useDll: true,
      dll: [
        {
          name: 'bundle',
          entry: ['react', 'react-dom', 'react-router', 'react-redux', 'redux-saga', 'react-router-dom', 'axios'],
        },
      ],
      server: {
        port: 7227,
        proxy: {
          '/local': {
            target: 'http://127.0.0.1:8028/static/cdn',
            pathRewrite: { '^/local': '' },
          },
        },
      },
    },
    // const apiUrl = 'http://open.ixvz.io/api/file/upload';
    deployOptions: {
      url: 'http://open.ixvz.io/api/file/upload',
    },
  };
};
@babel/core@babel/preset-env@babel/preset-typescript@babel/types@types/babel__core@types/gulp@types/gulp-babel@types/gulp-sourcemaps@types/node@types/prettier@types/through2gulp-babelgulp-cleangulp-lessgulp-sourcemapsgulp-typescriptgulp-utilprettierthrough2typescript@babel/plugin-proposal-decorators@babel/plugin-transform-runtime@babel/register@types/archiver@types/chalk@types/commander@types/figlet@types/merge2@types/request@types/webpack@types/whicharchiverbabel-plugin-transform-class-propertiesbabel-plugin-transform-decorators-legacycommanderfigletgulpgulp-cligulp-rimrafmerge2requestts-nodewebpackwhich@babel/plugin-proposal-class-properties@babel/plugin-syntax-dynamic-import@commitlint/cli@commitlint/config-conventional@types/copy@types/inquirer@types/jest@types/webpack-dev-server@typescript-eslint/eslint-plugin@typescript-eslint/parserautoprefixerbabel-eslintbabel-loaderbabel-plugin-importcase-sensitive-paths-webpack-pluginchalkclean-webpack-plugincopycopy-webpack-plugincross-envcss-loadereslinteslint-config-prettiereslint-plugin-jsx-control-statementseslint-plugin-prettiereslint-plugin-typescriptfile-loaderfriendly-errors-webpack-pluginhtml-webpack-pluginhtml-webpack-tags-pluginignore-loaderinquirerjestjson-loaderlessless-loaderlicense-checker-webpack-pluginlint-stagedmini-css-extract-pluginpostcss-loaderprogress-bar-webpack-pluginraw-loadersasssass-loaderspeed-measure-webpack-pluginstyle-loaderstylelintstylelint-config-standardstylelint-webpack-pluginstylusstylus-loadersvg-sprite-loaderterser-webpack-plugints-jestts-loaderunzip2url-loaderwebpack-bundle-analyzerwebpack-cliwebpack-dev-serverwebpack-filter-warnings-pluginwebpack-manifest-pluginwebpack-mergewebpackbarmomenteslint-plugin-react@babel/preset-reacthusky@types/filesize@types/gulp-uglify@types/single-line-logfilesizegulp-uglifyoptimize-css-assets-webpack-pluginsingle-line-log
1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

4 years ago

1.1.1

4 years ago

1.1.2

4 years ago

1.1.0

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago