├── .eslintignore ├── .eslintrc.js ├── .github └── workflows │ └── npmpublish.yml ├── .gitignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── commitlint.config.js ├── config └── config.ts ├── docs ├── example │ └── index.md ├── guide │ ├── cli.md │ ├── index.md │ └── start.md ├── index.md ├── plugins │ └── index.md └── setting │ ├── index.md │ ├── vite.md │ └── webpack.md ├── example ├── with-antd │ ├── .browserslistrc │ ├── .eslintrc.js │ ├── .gitignore │ ├── hull.conf.ts │ ├── index.d.ts │ ├── package.json │ ├── src │ │ └── index.tsx │ └── tsconfig.json └── with-postcss │ ├── .browserslistrc │ ├── .eslintrc.js │ ├── .gitignore │ ├── hull.conf.ts │ ├── index.d.ts │ ├── package.json │ ├── postcss.config.js │ ├── src │ ├── app.css │ ├── app.module.less │ ├── app.tsx │ ├── index.tsx │ └── static │ │ └── logo.svg │ └── tsconfig.json ├── lerna.json ├── package.json ├── packages ├── babel-preset-hull-app │ ├── .npmignore │ ├── CHANGELOG.md │ ├── package.json │ ├── src │ │ ├── create.ts │ │ └── index.ts │ └── tsconfig.json ├── eslint-config-hull-app │ ├── .npmignore │ ├── CHANGELOG.md │ ├── index.js │ ├── package.json │ ├── react.js │ └── vue.js ├── hull-build │ ├── .npmignore │ ├── CHANGELOG.md │ ├── README.md │ ├── package.json │ ├── public │ │ └── index.html │ ├── src │ │ ├── build │ │ │ ├── defineConfig.ts │ │ │ ├── getLoaderConfig.ts │ │ │ ├── getViteConfig.ts │ │ │ ├── getWebpackConfig.ts │ │ │ ├── index.ts │ │ │ ├── viteAction.ts │ │ │ └── webpackAction.ts │ │ ├── constants │ │ │ ├── index.ts │ │ │ ├── webpack.common.conf.ts │ │ │ ├── webpack.dev.conf.ts │ │ │ └── webpack.prod.conf.ts │ │ ├── features │ │ │ └── codeSplitting.ts │ │ ├── global.d.ts │ │ ├── index.ts │ │ └── types │ │ │ └── index.ts │ └── tsconfig.json ├── hull-cli │ ├── .npmignore │ ├── CHANGELOG.md │ ├── bin │ │ └── index.js │ ├── package-lock.json │ ├── package.json │ ├── src │ │ ├── global.d.ts │ │ └── index.ts │ ├── template │ │ ├── react-js │ │ │ ├── .browserslistrc │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── hull.conf.js │ │ │ ├── jsconfig.json │ │ │ ├── package.json │ │ │ └── src │ │ │ │ ├── app.css │ │ │ │ ├── app.jsx │ │ │ │ ├── app.module.less │ │ │ │ ├── index.jsx │ │ │ │ └── static │ │ │ │ └── logo.svg │ │ ├── react-ts │ │ │ ├── .browserslistrc │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── hull.conf.ts │ │ │ ├── index.d.ts │ │ │ ├── package.json │ │ │ ├── src │ │ │ │ ├── app.css │ │ │ │ ├── app.module.less │ │ │ │ ├── app.tsx │ │ │ │ ├── index.tsx │ │ │ │ └── static │ │ │ │ │ └── logo.svg │ │ │ └── tsconfig.json │ │ ├── vue-js │ │ │ ├── .browserslistrc │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── hull.conf.js │ │ │ ├── jsconfig.json │ │ │ ├── package.json │ │ │ └── src │ │ │ │ ├── App.vue │ │ │ │ ├── app.css │ │ │ │ ├── index.ts │ │ │ │ ├── shims-vue.d.ts │ │ │ │ └── static │ │ │ │ └── logo.png │ │ └── vue-ts │ │ │ ├── .browserslistrc │ │ │ ├── .eslintrc.js │ │ │ ├── .gitignore │ │ │ ├── hull.conf.ts │ │ │ ├── package.json │ │ │ ├── src │ │ │ ├── App.vue │ │ │ ├── app.css │ │ │ ├── index.ts │ │ │ ├── shims-vue.d.ts │ │ │ └── static │ │ │ │ └── logo.png │ │ │ └── tsconfig.json │ └── tsconfig.json ├── hull-utils │ ├── .npmignore │ ├── CHANGELOG.md │ ├── package.json │ ├── src │ │ ├── config.ts │ │ ├── getExistFile.ts │ │ ├── getFileExport.ts │ │ ├── getModulesFromConfig.ts │ │ ├── global.d.ts │ │ ├── index.ts │ │ ├── log.ts │ │ ├── registerNodeCiBabel.ts │ │ ├── startStaticServer.ts │ │ └── usePort.ts │ └── tsconfig.json ├── vite-plugin-babel-plugins │ ├── .npmignore │ ├── CHANGELOG.md │ ├── package.json │ ├── src │ │ ├── global.d.ts │ │ └── index.ts │ └── tsconfig.json └── vite-plugin-html │ ├── .npmignore │ ├── CHANGELOG.md │ ├── package.json │ ├── src │ ├── htmlPlugin.ts │ ├── index.ts │ ├── minifyHtml.ts │ └── typing.ts │ └── tsconfig.json ├── public └── images │ ├── code.jpg │ ├── init.png │ ├── logo.ico │ ├── logo.png │ └── pics.jpg ├── script ├── install.sh └── release.sh ├── test.md └── yarn.lock /.eslintignore: -------------------------------------------------------------------------------- 1 | example -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['./packages/eslint-config-hull-app/index.js', './packages/eslint-config-hull-app/vue.js'], 3 | rules: { 4 | '@typescript-eslint/explicit-module-boundary-types': 0, 5 | '@typescript-eslint/naming-convention': 0, 6 | 'require-atomic-updates': 0, 7 | }, 8 | }; 9 | -------------------------------------------------------------------------------- /.github/workflows/npmpublish.yml: -------------------------------------------------------------------------------- 1 | name: Create Release CI 2 | 3 | on: 4 | push: 5 | tags: 6 | - v* 7 | 8 | jobs: 9 | PUBLISH: 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | with: 15 | fetch-depth: 0 16 | - run: git fetch --prune 17 | - name: Use Node.js 14 18 | uses: actions/setup-node@v1 19 | with: 20 | node-version: 14 21 | registry-url: https://registry.npmjs.org/ 22 | - run: yarn install 23 | - run: npm run build 24 | - run: npm run lerna:publish 25 | env: 26 | NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | build 4 | # umi 5 | .umi 6 | .umi-production 7 | .umi-test -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 luoguoxiong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hulljs 2 | 3 | easy and quickly to build you web App 4 | 5 | hulljs 是通过更简单的配置、更快的构建web应用(react、vue3)。 6 | 7 | hulljs 支持vite和webpack两种构建方式。 8 | 9 | ## Getting Started 10 | 11 | ### install 12 | 13 | ```shell 14 | # 使用 npm 安装 CLI 15 | $ npm install -g @hulljs/cli 16 | 17 | # OR 使用 yarn 安装 CLI 18 | $ yarn global add @hulljs/cli 19 | 20 | # OR 安装了 cnpm,使用 cnpm 安装 CLI 21 | $ cnpm install -g @hulljs/cli 22 | ``` 23 | 24 | ### init project 25 | ```shell 26 | $ hull init 27 | ``` 28 | 29 | ![](https://github.com/luoguoxiong/hulljs/blob/main/public/images/init.png?raw=true) 30 | 31 | 32 | ### dev 33 | ```shell 34 | # webpack devServer 35 | hull dev 36 | 37 | # vite devServer 38 | hull dev --vite 39 | 40 | # 启用某个端口 41 | hull dev --port 8000 42 | ``` 43 | 44 | ### build 45 | ```shell 46 | # webpack 构建 47 | hull build 48 | 49 | # vite 构建 50 | hull build --vite 51 | 52 | # 启用打包分析 53 | hull build --vite --analyzer 54 | ``` 55 | 56 | ### server 57 | ```shell 58 | # 启用webpack构建后,访问静态网页资源 59 | hull server 60 | 61 | # 启用vite构建后,访问静态网页资源 62 | hull server --vite 63 | 64 | # 启用vite构建后,指定某个端口访问静态网页资源 65 | hull server --vite --port 6001 66 | ``` -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | '@commitlint/config-conventional', 4 | ], 5 | }; 6 | 7 | -------------------------------------------------------------------------------- /config/config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from 'umi'; 2 | 3 | export default defineConfig({ 4 | title: 'hulljs', 5 | favicon: '/images/logo.png', 6 | logo: '/images/logo.png', 7 | mode: 'site', 8 | outputPath: './dist', 9 | hash: true, 10 | navs: [ 11 | { 12 | title: '文档', 13 | path: '/guide', 14 | }, 15 | { 16 | title: '配置', 17 | path: '/setting', 18 | }, 19 | { 20 | title: '工具', 21 | path: '/plugins', 22 | }, 23 | { 24 | title: 'example', 25 | path: '/example', 26 | }, 27 | { 28 | title: 'Github', 29 | path: 'https://github.com/luoguoxiong/hulljs', 30 | }, 31 | ], 32 | // { 33 | // title: 'utils', 34 | // path: '/utils', 35 | // }, 36 | // { 37 | // title: 'hooks', 38 | // path: '/hooks', 39 | // }, 40 | // { 41 | // title: 'components', 42 | // path: '/components', 43 | // }, 44 | // { 45 | // title: 'constants', 46 | // path: '/constants', 47 | // }, 48 | // { 49 | // title: 'GitLab', 50 | // path: 'https://gitlab.codemao.cn/frontend/new-retail/dcc/dcc-tool-kit', 51 | // }, 52 | // ], 53 | }); 54 | -------------------------------------------------------------------------------- /docs/example/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | nav: 3 | title: example 4 | order: 0 5 | toc: menu 6 | --- 7 | 8 | # example 9 | 10 | ## [with-antd](https://github.com/luoguoxiong/hulljs/tree/main/example/with-antd) 11 | 12 | ## [with-postcss](https://github.com/luoguoxiong/hulljs/tree/main/example/with-postcss) -------------------------------------------------------------------------------- /docs/guide/cli.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: CLI 命令 3 | order: 2 4 | --- 5 | 6 | # CLI 命令 7 | ## 查看所有命令及帮助 8 | ```shell 9 | hull --help 10 | ``` 11 | 12 | ## dev 13 | ```shell 14 | # webpack devServer 15 | hull dev 16 | 17 | # vite devServer 18 | hull dev --vite 19 | 20 | # 启用某个端口 21 | hull dev --port 8000 22 | ``` 23 | 24 | ## build 25 | ```shell 26 | # webpack 构建 27 | hull build 28 | 29 | # vite 构建 30 | hull build --vite 31 | 32 | # 启用打包分析 33 | hull build --vite --analyzer 34 | ``` 35 | 36 | ## server 37 | ```shell 38 | # 启用webpack构建后,访问静态网页资源 39 | hull server 40 | 41 | # 启用vite构建后,访问静态网页资源 42 | hull server --vite 43 | 44 | # 启用vite构建后,指定某个端口访问静态网页资源 45 | hull server --vite --port 6001 46 | ``` -------------------------------------------------------------------------------- /docs/guide/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 关于hulljs 3 | order: 1 4 | --- 5 | 6 | # 关于hulljs 7 | 8 | ## 简介 9 | hulljs 是通过更简单的配置、更快的构建web应用 10 | 11 | 支持Webpack、Vite 两种构建方式 12 | 13 | 支持React、Vue3 14 | 15 | ## 设计原理 16 | * 对webpack和vite配置进行求同存异。 17 | * 熟悉React和Vue3常用的babel插件、vite插件,根据不同构建使用对应框架配置。 18 | ![](/images/pics.jpg) -------------------------------------------------------------------------------- /docs/guide/start.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: 快速开始 3 | order: 1 4 | --- 5 | # 快速开始 6 | 7 | ## 安装 node 8 | Hulljs 项目基于node,需确保 node 环境(>=14.0.0)。 9 | 10 | ## 安装 cli 11 | ```shell 12 | # 使用 npm 安装 CLI 13 | $ npm install -g @hulljs/cli 14 | 15 | # OR 使用 yarn 安装 CLI 16 | $ yarn global add @hulljs/cli 17 | 18 | # OR 安装了 cnpm,使用 cnpm 安装 CLI 19 | $ cnpm install -g @hulljs/cli 20 | ``` 21 | ## 项目初始化 22 | ```shell 23 | $ hull init 24 | ``` 25 | app-name 遵循 npm package.json name字段的规范 26 | 27 | ![](/images/init.png) 28 | 29 | ## 其他CLI命令 30 | ```shell 31 | Usage: 32 | $ hull [options] 33 | 34 | Commands: 35 | init create app project! 36 | dev Start dev server! 37 | build Build web app resource! 38 | server Start static server for production app! 39 | 40 | For more info, run any command with the `--help` flag: 41 | $ hull init --help 42 | $ hull dev --help 43 | $ hull build --help 44 | $ hull server --help 45 | 46 | Options: 47 | -v, --version Display version number 48 | -h, --help Display this message 49 | ``` -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | title: hulljs 3 | order: 10 4 | hero: 5 | title: hulljs 6 | desc: easy and quickly to build you web App 7 | actions: 8 | - text: 开发指南 9 | link: ./guide/start 10 | features: 11 | - icon: https://gw.alipayobjects.com/zos/bmw-prod/7659205c-6637-4fa2-8529-d32e5818304b/k7htflfb_w144_h144.png 12 | title: Vue3/React 13 | desc: 轻松构建web App 14 | - icon: https://webpack.docschina.org/icon-square-small-slack.9281492bb267314634b4.png 15 | title: Webpack/Vite 16 | desc: 支持两种构建工具 17 | - icon: https://gw.alipayobjects.com/zos/bmw-prod/7a26c287-d7d8-42d6-8a55-c9aa4c097149.webp 18 | title: easy setting 19 | desc: 简单的配置 20 | footer: hulljs
Open-source MIT Licensed | Copyright © 2022-present
Docs by [dumi](https://d.umijs.org) 21 | --- 22 | -------------------------------------------------------------------------------- /docs/plugins/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | nav: 3 | title: 插件工具 4 | order: 2 5 | toc: menu 6 | --- 7 | 8 | # hulljs 插件工具 9 | 10 | ## babel-preset-hull-app 11 | 提供了React、Vue3的babel插件集 12 | 13 | eg: vue3使用 .babelrc 14 | ```json 15 | { 16 | "presets": [ 17 | ["@hulljs/babel-preset-hull-app", 18 | { 19 | "isTypeScript": true, 20 | "projectType": "vue3", 21 | } 22 | ] 23 | ] 24 | } 25 | ``` 26 | 27 | eg: react使用 .babelrc 28 | ```json 29 | { 30 | "presets": [ 31 | ["@hulljs/babel-preset-hull-app", 32 | { 33 | "isTypeScript": true, 34 | "projectType": "react", 35 | } 36 | ] 37 | ] 38 | } 39 | ``` 40 | 41 | ## eslint-config-hull-app 42 | 统一lints规范工具 43 | ```js 44 | // .eslintrc.js 45 | // vue 46 | module.exports = { 47 | extends: ['@hulljs/eslint-config-hull-app/vue'] 48 | }; 49 | // react 50 | module.exports = { 51 | extends: ['@hulljs/eeslint-config-hull-app/react'] 52 | }; 53 | ``` 54 | ## vite-plugin-babel-plugins 55 | vite插件 使用额外的babel插件进行构建 56 | 57 | eg: 使用babel-plugin-import 58 | ```js 59 | import viteBabelPlugins from '@hulljs/vite-plugin-babel-plugins'; 60 | viteBabelPlugins( 61 | [ 62 | ["babel-plugin-import", { "libraryName": "antd", "libraryDirectory": "es"}] 63 | ] 64 | ) 65 | ``` 66 | ## vite-plugin-html 67 | vite 插件 类似于webpack-html-plugin 68 | 69 | eg: 70 | ```js 71 | import { createHtmlPlugin } from '@hulljs/vite-plugin-html'; 72 | createHtmlPlugin({ 73 | minify: true, 74 | entry: '/src/main.js', 75 | template: path.resolve(__dirname, './public/index.html'), 76 | inject: { 77 | title: 'welcome-use-hulljs', 78 | }, 79 | }) 80 | ``` 81 | 82 | ```html 83 | 84 | 85 | 86 | 87 | <%= htmlWebpackPlugin.options.title %> 88 | 89 | 90 |
91 | 92 | 93 | ``` -------------------------------------------------------------------------------- /docs/setting/index.md: -------------------------------------------------------------------------------- 1 | --- 2 | nav: 3 | title: hull-conf.js 配置 4 | order: 0 5 | toc: menu 6 | --- 7 | 8 | # 公共配置 9 | 1. 配置文件在项目根目录,支持hull.conf.js或hull.config.ts 10 | 2. 支持导出一个函数或者一个对象 11 | eg: 函数形式 12 | 13 | 函数:能拿到env参数,production或者development,可以根据这个值去区分生成跟开发环境的配置差异 14 | ```js 15 | import path from 'path'; 16 | 17 | export default (env) => { 18 | console.log('env:', env); 19 | return { 20 | projectType: 'react', 21 | entry: path.resolve(__dirname, './src/index'), 22 | }; 23 | }; 24 | ``` 25 | eg: 对象形式 26 | ```js 27 | import path from 'path'; 28 | 29 | export default { 30 | projectType: 'vue3', 31 | entry: path.resolve(__dirname, './src/index'), 32 | }; 33 | ``` 34 | 35 | ## projectType 36 | 37 | - Type: `string` 38 | - Default: `react` 39 | 可选 `react`、`vue3` 40 | 约定项目构建规则 41 | 42 | ## entry 43 | - Type: `string` 44 | 打包入口 45 | ## outputPath 46 | - Type: `string` 47 | 打包出口 48 | 49 | ## outputPublicPath 50 | - Type: `string` 51 | 52 | - Default: `/` 53 | 54 | 打包出口公共路径,开发环境默认/,生产环境推荐使用CDN地址。 55 | 56 | ## resolveAlias 57 | - Type: `object` 58 | 默认会从tsconfig.json或jsconfig.json配置中读取compilerOptions.paths 59 | ```js 60 | export default { 61 | resolveAlias: { 62 | foo: '/tmp/a/b/foo', 63 | }, 64 | }; 65 | ``` 66 | ## shouldUseSourceMap 67 | - Type: `boolean` 68 | 69 | - Default: false 70 | 71 | 在开发环境默认会开启,生产环境默认不生成sourceMap;如果生产需要生成,需将该配置改为true 72 | 73 | ## extraBabelPlugins 74 | - Type: Array 75 | - Default: [] 76 | 额外配置的babel插件 77 | ```js 78 | export default { 79 | extraBabelPlugins: [ 80 | ['import', 81 | { 82 | 'libraryName': 'antd', 83 | 'style': true, 84 | }], 85 | ], 86 | } 87 | ``` 88 | 89 | ## extraBabelPresets 90 | 91 | - Type: Array 92 | - Default: [] 93 | 额外配置的babel Presets 94 | 95 | ## fileSizeLimit 96 | - Type: number 97 | - Default: 1000 (1k) 98 | 针对图片资源、svg等,进行base64编译的阈值 99 | 100 | ## htmlPluginOpts 101 | - Type: `object` 102 | 103 | ```js 104 | export default { 105 | htmlPluginOpts: { 106 | template: path.resolve(__dirname, './public/index.html'), 107 | inject: { 108 | title: 'welcome-use-hulljs', 109 | }, 110 | } 111 | } 112 | ``` 113 | `ejs语法`统一使用<%= htmlWebpackPlugin.options.title %>格式 114 | ```html 115 | 116 | 117 | 118 | 119 | <%= htmlWebpackPlugin.options.title %> 120 | 121 | 122 |
123 | 124 | 125 | ``` 126 | ## definePluginOptions 127 | - Type: `object` 128 | [DefinePlugin 插件配置](https://webpack.js.org/plugins/define-plugin/#root) 129 | 130 | ## isUseBundleAnalyzer 131 | - Type: `boolean` 132 | - Default: false 133 | 生产环境是否生成打包构建分析 134 | 135 | ## devServer 136 | - Type: `object` 137 | 138 | ```js 139 | export default { 140 | devServer: { 141 | port: 8080, 142 | https: false 143 | } 144 | } 145 | ``` 146 | 147 | ## sassLoaderOptions 148 | - Type: `object` 149 | sassLoader配置 150 | 151 | ## lessLoaderOptions 152 | - Type: `object` 153 | lessLoader配置 154 | 155 | ## proxy 156 | 157 | * Type: `object` 158 | 开发服务器配置自定义代理规则 159 | 160 | ```javascript 161 | export default { 162 | proxy: { 163 | '/api': 'http://localhost:3000', 164 | } 165 | } 166 | ``` 167 | 168 | ## postcss 配置 169 | 在项目根目录创建postcss.config.js或postcss.config.cjs进行配置,已设置postcss-preset-env 170 | 171 | postcss 配置,它期望接收与 postcss.config.js 一致的格式。但对于 plugins 属性有些特别,只接收使用 [数组格式](https://github.com/postcss/postcss-load-config/blob/main/README.md#array)。 172 | 173 | 174 | ```js 175 | module.exports = { 176 | plugins: [ 177 | require('postcss-px-to-viewport')({ 178 | viewportWidth: 750, 179 | unitPrecision: 3, 180 | viewportUnit: 'vw', 181 | selectorBlackList: ['.ignore'], 182 | minPixelValue: 1, 183 | mediaQuery: false, 184 | }), 185 | ], 186 | }; 187 | ``` 188 | 189 | ## 关于样式 190 | 191 | 1. 内部集成了less和sass两种样式方案。 192 | 2. css module,统一使用xx.module.(less|sass|css)命名规范。 193 | 194 | ## 关于浏览器兼容性 195 | 196 | 针对js模块使用了@babel/preset-env,css模块使用了postcss-preset-env。都是根据根目录的.browserslistrc进行浏览器解析 197 | 198 | eg: 199 | 200 | ```browserlistrc 201 | [production] 202 | >0.2% 203 | not dead 204 | not op_mini all 205 | 206 | [development] 207 | last 1 chrome version 208 | last 1 firefox version 209 | last 1 safari version 210 | ``` 211 | 212 | 注意:由于开启babel-loader缓存,如果.browserlistrc修改了,需要手动删除babel缓存文件`node_modules/.cache`文件,重新构建 213 | -------------------------------------------------------------------------------- /docs/setting/vite.md: -------------------------------------------------------------------------------- 1 | --- 2 | nav: 3 | title: vite 专属配置 4 | order: 2 5 | toc: menu 6 | --- 7 | # vite 专属配置 8 | 9 | ## viteExtraBuildOptions 10 | 11 | * Type: `ViteExtraBuildOptions` 12 | 13 | 额外的Vite构建参数配置 14 | 15 | ```js 16 | import { UserConfig, BuildOptions } from 'vite'; 17 | 18 | type ViteExtraBuildOptions = Omit; 19 | ``` 20 | 21 | ## viteExtraPlugins 22 | 23 | 额外的Vite插件 24 | 25 | * Type: `PluginOption` 26 | 27 | ```js 28 | import { PluginOption } from 'vite'; 29 | ``` -------------------------------------------------------------------------------- /docs/setting/webpack.md: -------------------------------------------------------------------------------- 1 | --- 2 | nav: 3 | title: webpack 专属配置 4 | order: 1 5 | toc: menu 6 | --- 7 | # webpack 专属配置 8 | ## extraWebpackPlugins 9 | 10 | - Type: Array 11 | - Default: [] 12 | 额外的webpack插件 13 | 14 | ## extraModuleRules 15 | 16 | - Type: Array 17 | - Default: [] 18 | 额外的webpackModuleRules规则配置 19 | 20 | ## splitChunks 21 | 22 | - Type: `object` 23 | Webpack 代码分割 24 | 25 | ```js 26 | export default { 27 | splitChunks: { 28 | cacheGroups: { 29 | reactChunks: { 30 | name: 'reactChunks', 31 | test: (module) => new RegExp(/react/).test(module.context), 32 | chunks: 'all', 33 | }, 34 | }, 35 | } 36 | } 37 | ``` 38 | 39 | ## splitChunksLibary 40 | 41 | - Type: `object` 42 | 对node_modules的某些包进行分包 43 | ```js 44 | export default { 45 | splitChunksLibary: { 46 | "react": ["react", "react-dom"], 47 | "antd": ["antd"] 48 | } 49 | } 50 | ``` 51 | ![](/images/code.jpg) 52 | -------------------------------------------------------------------------------- /example/with-antd/.browserslistrc: -------------------------------------------------------------------------------- 1 | [production] 2 | >0.2% 3 | not dead 4 | not op_mini all 5 | 6 | [development] 7 | last 1 chrome version 8 | last 1 firefox version 9 | last 1 safari version -------------------------------------------------------------------------------- /example/with-antd/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@hulljs/eslint-config-hull-app/react'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/with-antd/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules -------------------------------------------------------------------------------- /example/with-antd/hull.conf.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | export default { 3 | projectType: 'react', 4 | entry: path.resolve(__dirname, './src/index'), 5 | extraBabelPlugins: [ 6 | ['import', 7 | { 8 | 'libraryName': 'antd', 9 | "libraryDirectory": "es", 10 | 'style': true, 11 | }], 12 | ], 13 | splitChunksLibary: { 14 | "react": ["react", "react-dom"], 15 | "antd": ["antd"], 16 | "polyfill":["@babel/polyfill"] 17 | } 18 | }; 19 | -------------------------------------------------------------------------------- /example/with-antd/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.svg' 2 | declare module '*.css' 3 | declare module '*.less' 4 | declare module '*.scss' 5 | -------------------------------------------------------------------------------- /example/with-antd/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-antd", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "dev": "hull dev", 6 | "dev:vite": "hull dev --vite", 7 | "build": "hull build", 8 | "build:vite": "hull build --vite", 9 | "server": "hull server", 10 | "server:vite": "hull server --vite" 11 | }, 12 | "devDependencies": { 13 | "@hulljs/cli": "^0.7.0", 14 | "@hulljs/eslint-config-hull-app": "^0.1.0", 15 | "@types/react": "^18.0.9", 16 | "@types/react-dom": "^18.0.4", 17 | "babel-plugin-import": "^1.13.5" 18 | }, 19 | "dependencies": { 20 | "antd": "^4.21.0", 21 | "react": "^17.0.1", 22 | "react-dom": "^17.0.1" 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/with-antd/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import {Button} from 'antd' 4 | 5 | ReactDOM.render( 6 | , 7 | document.getElementById('root'), 8 | ); -------------------------------------------------------------------------------- /example/with-antd/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "baseUrl": ".", 5 | "jsx": "react", 6 | "paths": { 7 | "@/src/*": ["./src/*"] 8 | } 9 | }, 10 | "files": ["./index.d.ts"], 11 | "include": ["src/**/*"], 12 | "exclude": ["node_modules"] 13 | } 14 | -------------------------------------------------------------------------------- /example/with-postcss/.browserslistrc: -------------------------------------------------------------------------------- 1 | [production] 2 | >0.2% 3 | not dead 4 | not op_mini all 5 | 6 | [development] 7 | last 1 chrome version 8 | last 1 firefox version 9 | last 1 safari version -------------------------------------------------------------------------------- /example/with-postcss/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@hulljs/eslint-config-hull-app/react'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/with-postcss/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules -------------------------------------------------------------------------------- /example/with-postcss/hull.conf.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | 3 | export default { 4 | projectType: 'react', 5 | entry: path.resolve(__dirname, './src/index'), 6 | }; 7 | -------------------------------------------------------------------------------- /example/with-postcss/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.svg' 2 | declare module '*.css' 3 | declare module '*.less' 4 | declare module '*.scss' 5 | -------------------------------------------------------------------------------- /example/with-postcss/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "with-postcss", 3 | "version": "0.1.0", 4 | "scripts": { 5 | "dev": "hull dev", 6 | "dev:vite": "hull dev --vite", 7 | "build": "hull build", 8 | "build:vite": "hull build --vite", 9 | "server": "hull server", 10 | "server:vite": "hull server --vite" 11 | }, 12 | "devDependencies": { 13 | "@hulljs/cli": "^0.7.0", 14 | "@hulljs/eslint-config-hull-app": "^0.1.0", 15 | "@types/react": "^18.0.9", 16 | "@types/react-dom": "^18.0.4", 17 | "postcss-px-to-viewport": "^1.1.1" 18 | }, 19 | "dependencies": { 20 | "react": "^17.0.1", 21 | "react-dom": "^17.0.1" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/with-postcss/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | require('postcss-px-to-viewport')({ 4 | viewportWidth: 750, 5 | unitPrecision: 3, 6 | viewportUnit: 'vw', 7 | selectorBlackList: ['.ignore'], 8 | minPixelValue: 1, 9 | mediaQuery: false, 10 | }), 11 | ], 12 | }; 13 | -------------------------------------------------------------------------------- /example/with-postcss/src/app.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /example/with-postcss/src/app.module.less: -------------------------------------------------------------------------------- 1 | 2 | .App { 3 | text-align: center; 4 | } 5 | 6 | .App-logo { 7 | height: 40vmin; 8 | pointer-events: none; 9 | border-radius: 50%; 10 | } 11 | 12 | @media (prefers-reduced-motion: no-preference) { 13 | .App-logo { 14 | animation: App-logo-spin infinite 20s linear; 15 | } 16 | } 17 | 18 | .App-header { 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | min-height: 100vh; 24 | color: white; 25 | font-size: calc(10px + 2vmin); 26 | background-color: #282c34; 27 | } 28 | 29 | .App-link { 30 | color: #61dafb; 31 | } 32 | 33 | @keyframes App-logo-spin { 34 | from { 35 | transform: rotate(0deg); 36 | } 37 | to { 38 | transform: rotate(360deg); 39 | } 40 | } -------------------------------------------------------------------------------- /example/with-postcss/src/app.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from '@/src/static/logo.svg'; 3 | import styles from '@/src/app.module.less'; 4 | import './app.css'; 5 | 6 | function App() { 7 | return ( 8 |
9 |
10 | logo 14 |

15 | Edit src/app.js and save to reload. 16 |

17 | 23 | Learn React 24 | 25 |
26 |
27 | ); 28 | } 29 | 30 | export default App; 31 | -------------------------------------------------------------------------------- /example/with-postcss/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from '@/src/app'; 4 | 5 | ReactDOM.render( 6 | , 7 | document.getElementById('root'), 8 | ); 9 | -------------------------------------------------------------------------------- /example/with-postcss/src/static/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/with-postcss/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "baseUrl": ".", 5 | "jsx": "react", 6 | "paths": { 7 | "@/src/*": ["./src/*"] 8 | } 9 | }, 10 | "files": ["./index.d.ts"], 11 | "include": ["src/**/*"], 12 | "exclude": ["node_modules"] 13 | } 14 | -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "npmClient": "yarn", 3 | "useWorkspaces": true, 4 | "version": "0.8.2", 5 | "command": { 6 | "version": { 7 | "allowBranch": "master" 8 | } 9 | }, 10 | "publishConfig": { 11 | "access": "public" 12 | }, 13 | "changelogPreset": { 14 | "name": "conventionalcommits", 15 | "types": [ 16 | { 17 | "type": "feat", 18 | "section": "✨ Features | 新功能" 19 | }, 20 | { 21 | "type": "fix", 22 | "section": "🐛 Bug Fixes | Bug 修复" 23 | }, 24 | { 25 | "type": "chore", 26 | "section": "🚀 Chore | 构建/工程依赖/工具", 27 | "hidden": true 28 | }, 29 | { 30 | "type": "docs", 31 | "section": "📝 Documentation | 文档" 32 | }, 33 | { 34 | "type": "style", 35 | "section": "💄 Styles | 样式" 36 | }, 37 | { 38 | "type": "refactor", 39 | "section": "♻️ Code Refactoring | 代码重构" 40 | }, 41 | { 42 | "type": "perf", 43 | "section": "⚡ Performance Improvements | 性能优化" 44 | }, 45 | { 46 | "type": "test", 47 | "section": "✅ Tests | 测试", 48 | "hidden": true 49 | }, 50 | { 51 | "type": "revert", 52 | "section": "⏪ Revert | 回退", 53 | "hidden": true 54 | }, 55 | { 56 | "type": "build", 57 | "section": "📦‍ Build System | 打包构建" 58 | }, 59 | { 60 | "type": "ci", 61 | "section": "👷 Continuous Integration | CI 配置" 62 | } 63 | ], 64 | "issuePrefixes": [ 65 | "#" 66 | ], 67 | "issueUrlFormat": "{{host}}/{{owner}}/{{repository}}/issues/{{id}}", 68 | "commitUrlFormat": "{{host}}/{{owner}}/{{repository}}/commit/{{hash}}", 69 | "compareUrlFormat": "{{host}}/{{owner}}/{{repository}}/compare/{{previousTag}}...{{currentTag}}", 70 | "userUrlFormat": "{{host}}/{{user}}" 71 | }, 72 | "packages": [ 73 | "packages/*" 74 | ] 75 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "scripts": { 4 | "release": "bash ./script/release.sh", 5 | "install:all": "bash ./script/install.sh", 6 | "version": "lerna version --exact --no-commit-hooks --no-push --conventional-commits --force-git-tag", 7 | "start": "dumi dev", 8 | "build": "lerna run build", 9 | "build-doc": "dumi build", 10 | "bootstrap": "lerna bootstrap", 11 | "lerna:publish": "lerna publish from-package --yes" 12 | }, 13 | "gitHooks": { 14 | "pre-commit": "lint-staged", 15 | "commit-msg": "commitlint -eGIT_classnamesPARAMS $" 16 | }, 17 | "lint-staged": { 18 | "*.{js,jsx,ts,tsx}": [ 19 | "eslint --fix" 20 | ] 21 | }, 22 | "repository": { 23 | "type": "git", 24 | "url": "git+https://github.com/luoguoxiong/hulljs.git" 25 | }, 26 | "author": "luoguoxiong", 27 | "license": "ISC", 28 | "bugs": { 29 | "url": "https://github.com/luoguoxiong/hulljs/issues" 30 | }, 31 | "homepage": "https://github.com/luoguoxiong/hulljs#readme", 32 | "devDependencies": { 33 | "@commitlint/cli": "^8.3.5", 34 | "@commitlint/config-conventional": "^8.3.4", 35 | "@hulljs/eslint-config-hull-app": "^0.0.1", 36 | "conventional-changelog-angular-bitbucket": "^1.2.0", 37 | "dumi": "^1.1.42", 38 | "husky": "^8.0.1", 39 | "lerna": "^4.0.0", 40 | "lint-staged": "^10.0.7", 41 | "yorkie": "^2.0.0" 42 | }, 43 | "workspaces": [ 44 | "packages/*" 45 | ], 46 | "publishConfig": { 47 | "access": "public" 48 | }, 49 | "__npminstall_done": false 50 | } 51 | -------------------------------------------------------------------------------- /packages/babel-preset-hull-app/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | CHANGELOG.md 3 | tsconfig.json -------------------------------------------------------------------------------- /packages/babel-preset-hull-app/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 0.8.0 (2022-11-17) 7 | 8 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 9 | 10 | 11 | 12 | 13 | 14 | ## 0.7.0 (2022-11-17) 15 | 16 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 17 | 18 | 19 | 20 | 21 | 22 | ## 0.6.0 (2022-11-17) 23 | 24 | * feat: preset-env useBuiltIns使用usage模式 ([6f6dc42](https://github.com/luoguoxiong/hulljs/commit/6f6dc42)) 25 | 26 | 27 | 28 | 29 | 30 | ## 0.5.0 (2022-11-16) 31 | 32 | * feat: 升级preset ([a8eeab8](https://github.com/luoguoxiong/hulljs/commit/a8eeab8)) 33 | 34 | 35 | 36 | 37 | 38 | ## 0.4.0 (2022-11-14) 39 | 40 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 41 | 42 | 43 | 44 | 45 | 46 | ## 0.3.0 (2022-11-07) 47 | 48 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 49 | 50 | 51 | 52 | 53 | 54 | ## 0.2.0 (2022-08-31) 55 | 56 | * v0.0.1 ([abb7235](https://github.com/luoguoxiong/hulljs/commit/abb7235)) 57 | * v0.0.1 ([9741168](https://github.com/luoguoxiong/hulljs/commit/9741168)) 58 | * v0.0.1 ([fd6dff8](https://github.com/luoguoxiong/hulljs/commit/fd6dff8)) 59 | * v0.0.1 ([7bdb68f](https://github.com/luoguoxiong/hulljs/commit/7bdb68f)) 60 | * v0.0.1 ([0d7b9a0](https://github.com/luoguoxiong/hulljs/commit/0d7b9a0)) 61 | * v0.0.1 ([23a8219](https://github.com/luoguoxiong/hulljs/commit/23a8219)) 62 | * v0.0.1 ([2e7d627](https://github.com/luoguoxiong/hulljs/commit/2e7d627)) 63 | * v0.0.1-alpha.0 ([2bee034](https://github.com/luoguoxiong/hulljs/commit/2bee034)) 64 | * v0.0.1-alpha.0 ([91ec57e](https://github.com/luoguoxiong/hulljs/commit/91ec57e)) 65 | * v0.0.2 ([484bbd2](https://github.com/luoguoxiong/hulljs/commit/484bbd2)) 66 | * v0.0.2 ([93bde13](https://github.com/luoguoxiong/hulljs/commit/93bde13)) 67 | * v0.0.2 ([5869178](https://github.com/luoguoxiong/hulljs/commit/5869178)) 68 | * v0.0.2 ([c02f578](https://github.com/luoguoxiong/hulljs/commit/c02f578)) 69 | * v0.0.2-alpha.0 ([92972ca](https://github.com/luoguoxiong/hulljs/commit/92972ca)) 70 | * v0.0.4 ([64c2b6a](https://github.com/luoguoxiong/hulljs/commit/64c2b6a)) 71 | * v0.0.5 ([a332989](https://github.com/luoguoxiong/hulljs/commit/a332989)) 72 | * v0.0.6 ([45d2cdc](https://github.com/luoguoxiong/hulljs/commit/45d2cdc)) 73 | * v0.0.7 ([e4ab4fd](https://github.com/luoguoxiong/hulljs/commit/e4ab4fd)) 74 | * v0.0.8 ([b8131c9](https://github.com/luoguoxiong/hulljs/commit/b8131c9)) 75 | * v0.0.9 ([3c57a80](https://github.com/luoguoxiong/hulljs/commit/3c57a80)) 76 | * v0.1.0 ([da199ef](https://github.com/luoguoxiong/hulljs/commit/da199ef)) 77 | * v0.1.0 ([1e16cfc](https://github.com/luoguoxiong/hulljs/commit/1e16cfc)) 78 | * v0.1.0 ([9857d8a](https://github.com/luoguoxiong/hulljs/commit/9857d8a)) 79 | * v0.1.0 ([ef972e3](https://github.com/luoguoxiong/hulljs/commit/ef972e3)) 80 | * v0.1.0 ([3ac3e8b](https://github.com/luoguoxiong/hulljs/commit/3ac3e8b)) 81 | * v0.1.0 ([5e6c390](https://github.com/luoguoxiong/hulljs/commit/5e6c390)) 82 | * v0.1.0-alpha.0 ([23089e0](https://github.com/luoguoxiong/hulljs/commit/23089e0)) 83 | * v0.2.0 ([218cbd6](https://github.com/luoguoxiong/hulljs/commit/218cbd6)) 84 | * fix: add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b2)) 85 | * fix: babel-preset package.json ([7dfff2b](https://github.com/luoguoxiong/hulljs/commit/7dfff2b)) 86 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 87 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 88 | * fix: vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec72)) 89 | * feat: 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407)) 90 | * feat: cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6)) 91 | * feat: for vite ([2966cf9](https://github.com/luoguoxiong/hulljs/commit/2966cf9)) 92 | * feat: for vue ([705b275](https://github.com/luoguoxiong/hulljs/commit/705b275)) 93 | * feat: hull-preset-app ([36d3385](https://github.com/luoguoxiong/hulljs/commit/36d3385)) 94 | * feat: hullci ([94c8aa1](https://github.com/luoguoxiong/hulljs/commit/94c8aa1)) 95 | * feat: hullci template ([d83a676](https://github.com/luoguoxiong/hulljs/commit/d83a676)) 96 | * feat: ok ([824478b](https://github.com/luoguoxiong/hulljs/commit/824478b)) 97 | * feat: preset-hull-app ([c54033f](https://github.com/luoguoxiong/hulljs/commit/c54033f)) 98 | * feat: test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af)) 99 | * feat: test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701c)) 100 | * feat: test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cd)) 101 | * feat: test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da)) 102 | * feat: test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c)) 103 | * feat: test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43)) 104 | * feat: test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f59250)) 105 | * chore(build): release ([fa1ac7e](https://github.com/luoguoxiong/hulljs/commit/fa1ac7e)) 106 | * docs: 完善文档 ([02f0020](https://github.com/luoguoxiong/hulljs/commit/02f0020)) 107 | 108 | 109 | 110 | 111 | 112 | ## 0.1.0 (2022-07-28) 113 | 114 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 115 | 116 | 117 | 118 | 119 | 120 | ## 0.0.9 (2022-06-16) 121 | 122 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 123 | 124 | 125 | 126 | 127 | 128 | ## 0.0.8 (2022-06-12) 129 | 130 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 131 | 132 | 133 | 134 | 135 | 136 | ## 0.0.7 (2022-06-12) 137 | 138 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 139 | 140 | 141 | 142 | 143 | 144 | ## 0.0.6 (2022-06-11) 145 | 146 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 147 | 148 | 149 | 150 | 151 | 152 | ## 0.0.5 (2022-06-11) 153 | 154 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 155 | 156 | 157 | 158 | 159 | 160 | ## 0.0.4 (2022-06-11) 161 | 162 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 163 | 164 | 165 | 166 | 167 | 168 | ## 0.0.3 (2022-06-11) 169 | 170 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 171 | 172 | 173 | 174 | 175 | 176 | ## [0.1.0](https://github.com/luoguoxiong/hulljs/compare/v0.0.3...v0.1.0) (2022-06-11) 177 | 178 | 179 | ### 🐛 Bug Fixes | Bug 修复 180 | 181 | * add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b27e89bef094a0d7f3ade77122395a78bc0)) 182 | * babel-preset package.json ([7dfff2b](https://github.com/luoguoxiong/hulljs/commit/7dfff2b1dbcdf3ee9e25fbb95e19740b971c87d6)) 183 | 184 | 185 | 186 | ## 0.1.0 (2022-06-10) 187 | 188 | 189 | ### 📝 Documentation | 文档 190 | 191 | * 完善文档 ([02f0020](https://github.com/luoguoxiong/hulljs/commit/02f0020582221f1e6443d5f079a717c7a7c6c63f)) 192 | 193 | 194 | ### 🐛 Bug Fixes | Bug 修复 195 | 196 | * vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec7273b817f76ad359cfb8e9dabbb0eed7f04)) 197 | 198 | 199 | ### ✨ Features | 新功能 200 | 201 | * 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407fcaea1153ff421c41ead174539be99b9b)) 202 | * cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6e44439cb94d1080cc3e0ee6556271383c)) 203 | * for vite ([2966cf9](https://github.com/luoguoxiong/hulljs/commit/2966cf90503ae8aeab9227b89c8ea3ae905d2882)) 204 | * for vue ([705b275](https://github.com/luoguoxiong/hulljs/commit/705b2758cc3ce1ca2344ccca658a47f2a8fd7c78)) 205 | * hull-preset-app ([36d3385](https://github.com/luoguoxiong/hulljs/commit/36d3385fee4a9257e75d62debd8724d2de0f6ca9)) 206 | * hullci ([94c8aa1](https://github.com/luoguoxiong/hulljs/commit/94c8aa17cc0cf1d53027c87e9f9dca80bb7a5b3b)) 207 | * hullci template ([d83a676](https://github.com/luoguoxiong/hulljs/commit/d83a67617d322a09d0d48d1c871bb6422f26077c)) 208 | * preset-hull-app ([c54033f](https://github.com/luoguoxiong/hulljs/commit/c54033f34bad2175a470e9c0659d76b61ffd54a0)) 209 | * test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af4f4a0fac7ce23bf0e3aa89e4577d9073b)) 210 | * test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701cb048f668ff4ec2d1ee1cb21e8ef87f930)) 211 | * test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cdcdbdb51c0a09f54b980e19320e94eb02c)) 212 | * test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da4ad397f984352294fd4c66e994b35a74f)) 213 | * test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c0e6d9e1fbcc37bf3a5d659978c81289b0)) 214 | * test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43edde66d27b8d1eaed0fecd65d9b812587)) 215 | * test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f592508321fab77b739d9977e293b49063fb173)) 216 | 217 | 218 | 219 | ## [0.2.0](https://github.com/luoguoxiong/hulljs/compare/v0.1.0...v0.2.0) (2022-06-10) 220 | 221 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 222 | 223 | 224 | 225 | 226 | 227 | 228 | # [0.1.0](https://github.com/projects/luoguoxiong/repos/hulljs/compare/diff?targetBranch=refs%2Ftags%2Fv0.0.1&sourceBranch=refs%2Ftags%2Fv0.1.0) (2022-06-10) 229 | 230 | **Note:** Version bump only for package @hulljs/babel-preset-hull-app 231 | -------------------------------------------------------------------------------- /packages/babel-preset-hull-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hulljs/babel-preset-hull-app", 3 | "version": "0.8.0", 4 | "description": "", 5 | "type": "commonjs", 6 | "main": "./dist/index.js", 7 | "types": "./dist/index.d.js", 8 | "author": "", 9 | "scripts": { 10 | "build": "tsc", 11 | "watch": "tsc -w", 12 | "pub": "npm publish" 13 | }, 14 | "devDependencies": { 15 | "typescript": "^4.6.4" 16 | }, 17 | "license": "ISC", 18 | "dependencies": { 19 | "@babel/core": "7.12.3", 20 | "@babel/plugin-proposal-class-properties": "7.12.1", 21 | "@babel/plugin-proposal-decorators": "7.12.1", 22 | "@babel/plugin-proposal-do-expressions": "7.12.1", 23 | "@babel/plugin-proposal-export-default-from": "7.12.1", 24 | "@babel/plugin-proposal-export-namespace-from": "7.12.1", 25 | "@babel/plugin-proposal-nullish-coalescing-operator": "7.12.1", 26 | "@babel/plugin-proposal-optional-chaining": "7.12.1", 27 | "@babel/plugin-proposal-private-methods": "^7.18.6", 28 | "@babel/plugin-proposal-private-property-in-object": "^7.18.6", 29 | "@babel/plugin-syntax-dynamic-import": "7.8.3", 30 | "@babel/plugin-transform-modules-commonjs": "7.12.1", 31 | "@babel/plugin-transform-runtime": "7.12.1", 32 | "@babel/preset-env": "7.12.1", 33 | "@babel/preset-react": "7.12.1", 34 | "@babel/preset-typescript": "7.12.1", 35 | "@babel/runtime": "^7.17.9", 36 | "@vue/babel-plugin-jsx": "^1.1.1", 37 | "babel-plugin-react-require": "^3.1.3", 38 | "babel-plugin-transform-react-remove-prop-types": "^0.4.24", 39 | "core-js": "^3.26.1" 40 | }, 41 | "publishConfig": { 42 | "access": "public" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /packages/babel-preset-hull-app/src/create.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import { PersentRe, IGetBabelOptions } from './index'; 3 | export const persetForReact = (isProduction: boolean): PersentRe => ({ 4 | presets: [ 5 | [require.resolve('@babel/preset-react')], 6 | ], 7 | plugins: [ 8 | [require.resolve('babel-plugin-react-require')], 9 | ...(isProduction ? [[ 10 | require('babel-plugin-transform-react-remove-prop-types').default, 11 | { 12 | removeImport: true, 13 | }, 14 | ]] : []), 15 | ], 16 | }); 17 | 18 | export const persetForVue = (): PersentRe => ({ 19 | presets: [], 20 | plugins: [ 21 | require.resolve('@vue/babel-plugin-jsx'), 22 | ], 23 | }); 24 | 25 | export const presetForCommon = (opts: IGetBabelOptions): PersentRe => { 26 | 27 | const { isTypeScript } = opts; 28 | 29 | return { 30 | presets: [ 31 | ...(isTypeScript ? [[require.resolve('@babel/preset-typescript'), 32 | { 33 | allExtensions: true, 34 | isTSX: true, 35 | }]] : []), 36 | [require.resolve('@babel/preset-env'), { 37 | useBuiltIns: 'usage', 38 | corejs: 3, 39 | exclude: ['transform-typeof-symbol'], 40 | } ], 41 | ], 42 | plugins: [ 43 | require.resolve('@babel/plugin-syntax-dynamic-import'), 44 | require.resolve('@babel/plugin-proposal-export-default-from'), 45 | require.resolve('@babel/plugin-proposal-export-namespace-from'), 46 | require.resolve('@babel/plugin-proposal-do-expressions'), 47 | require.resolve('@babel/plugin-proposal-nullish-coalescing-operator'), 48 | require.resolve('@babel/plugin-proposal-optional-chaining'), 49 | [require.resolve('@babel/plugin-proposal-decorators'), 50 | { 51 | legacy: true, 52 | }, 53 | ], 54 | [require.resolve('@babel/plugin-proposal-class-properties'), 55 | { 56 | loose: true, 57 | }, 58 | ], 59 | [require.resolve('@babel/plugin-proposal-private-methods'), 60 | { 61 | loose: true, 62 | }, 63 | ], 64 | [ 65 | require.resolve('@babel/plugin-proposal-private-property-in-object'), 66 | { 67 | loose: true, 68 | }, 69 | ], 70 | [require.resolve('@babel/plugin-transform-runtime'), { 71 | version: require('@babel/runtime/package.json').version, 72 | /** 如果不设置absoluteRuntime,在ci调试环境会找不到@babel/runtime */ 73 | absoluteRuntime: path.dirname( 74 | require.resolve('@babel/runtime/package.json'), 75 | ), 76 | }], 77 | ], 78 | }; 79 | }; 80 | 81 | -------------------------------------------------------------------------------- /packages/babel-preset-hull-app/src/index.ts: -------------------------------------------------------------------------------- 1 | import { presetForCommon, persetForVue, persetForReact } from './create'; 2 | export interface IGetBabelOptions { 3 | projectType?: 'react' | 'vue3'; 4 | isTypeScript?: boolean; 5 | isProduction?: boolean; 6 | } 7 | export interface PersentRe{ 8 | presets: any[]; 9 | plugins: any[]; 10 | } 11 | 12 | // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types 13 | export default (_context: any, options: IGetBabelOptions): PersentRe => { 14 | 15 | const { isProduction = false, projectType } = options; 16 | 17 | const presetCommon = presetForCommon(options); 18 | 19 | const presetReact = persetForReact(isProduction); 20 | 21 | const persetVue = persetForVue(); 22 | 23 | const plugins = [ 24 | ...(projectType === 'react' ? presetReact.plugins : []), 25 | ...(projectType === 'vue3' ? persetVue.plugins : []), 26 | ...presetCommon.plugins, 27 | ]; 28 | const presets = [ 29 | ...(projectType === 'react' ? presetReact.presets : []), 30 | ...(projectType === 'vue3' ? persetVue.presets : []), 31 | ...presetCommon.presets, 32 | ]; 33 | 34 | return { 35 | plugins, 36 | presets, 37 | }; 38 | }; 39 | -------------------------------------------------------------------------------- /packages/babel-preset-hull-app/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "sourceMap": true, 8 | "resolveJsonModule": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "skipDefaultLibCheck": false, 12 | "declaration": true, 13 | "outDir": "./dist", 14 | "rootDir": "./src", 15 | "paths": { 16 | "@/*": ["./src/*"] 17 | } 18 | }, 19 | } -------------------------------------------------------------------------------- /packages/eslint-config-hull-app/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | CHANGELOG.md 3 | tsconfig.json -------------------------------------------------------------------------------- /packages/eslint-config-hull-app/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 0.8.0 (2022-11-17) 7 | 8 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 9 | 10 | 11 | 12 | 13 | 14 | ## 0.7.0 (2022-11-17) 15 | 16 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 17 | 18 | 19 | 20 | 21 | 22 | ## 0.6.0 (2022-11-17) 23 | 24 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 25 | 26 | 27 | 28 | 29 | 30 | ## 0.5.0 (2022-11-16) 31 | 32 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 33 | 34 | 35 | 36 | 37 | 38 | ## 0.4.0 (2022-11-14) 39 | 40 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 41 | 42 | 43 | 44 | 45 | 46 | ## 0.3.0 (2022-11-07) 47 | 48 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 49 | 50 | 51 | 52 | 53 | 54 | ## 0.2.0 (2022-08-31) 55 | 56 | * v0.0.1 ([abb7235](https://github.com/luoguoxiong/hulljs/commit/abb7235)) 57 | * v0.0.1 ([9741168](https://github.com/luoguoxiong/hulljs/commit/9741168)) 58 | * v0.0.1 ([fd6dff8](https://github.com/luoguoxiong/hulljs/commit/fd6dff8)) 59 | * v0.0.1 ([7bdb68f](https://github.com/luoguoxiong/hulljs/commit/7bdb68f)) 60 | * v0.0.1 ([0d7b9a0](https://github.com/luoguoxiong/hulljs/commit/0d7b9a0)) 61 | * v0.0.1 ([23a8219](https://github.com/luoguoxiong/hulljs/commit/23a8219)) 62 | * v0.0.1 ([2e7d627](https://github.com/luoguoxiong/hulljs/commit/2e7d627)) 63 | * v0.0.1-alpha.0 ([2bee034](https://github.com/luoguoxiong/hulljs/commit/2bee034)) 64 | * v0.0.1-alpha.0 ([91ec57e](https://github.com/luoguoxiong/hulljs/commit/91ec57e)) 65 | * v0.0.2 ([484bbd2](https://github.com/luoguoxiong/hulljs/commit/484bbd2)) 66 | * v0.0.2 ([93bde13](https://github.com/luoguoxiong/hulljs/commit/93bde13)) 67 | * v0.0.2 ([5869178](https://github.com/luoguoxiong/hulljs/commit/5869178)) 68 | * v0.0.2 ([c02f578](https://github.com/luoguoxiong/hulljs/commit/c02f578)) 69 | * v0.0.2-alpha.0 ([92972ca](https://github.com/luoguoxiong/hulljs/commit/92972ca)) 70 | * v0.0.4 ([64c2b6a](https://github.com/luoguoxiong/hulljs/commit/64c2b6a)) 71 | * v0.0.5 ([a332989](https://github.com/luoguoxiong/hulljs/commit/a332989)) 72 | * v0.0.6 ([45d2cdc](https://github.com/luoguoxiong/hulljs/commit/45d2cdc)) 73 | * v0.0.7 ([e4ab4fd](https://github.com/luoguoxiong/hulljs/commit/e4ab4fd)) 74 | * v0.0.8 ([b8131c9](https://github.com/luoguoxiong/hulljs/commit/b8131c9)) 75 | * v0.0.9 ([3c57a80](https://github.com/luoguoxiong/hulljs/commit/3c57a80)) 76 | * v0.1.0 ([da199ef](https://github.com/luoguoxiong/hulljs/commit/da199ef)) 77 | * v0.1.0 ([1e16cfc](https://github.com/luoguoxiong/hulljs/commit/1e16cfc)) 78 | * v0.1.0 ([9857d8a](https://github.com/luoguoxiong/hulljs/commit/9857d8a)) 79 | * v0.1.0 ([ef972e3](https://github.com/luoguoxiong/hulljs/commit/ef972e3)) 80 | * v0.1.0 ([3ac3e8b](https://github.com/luoguoxiong/hulljs/commit/3ac3e8b)) 81 | * v0.1.0 ([5e6c390](https://github.com/luoguoxiong/hulljs/commit/5e6c390)) 82 | * v0.1.0-alpha.0 ([23089e0](https://github.com/luoguoxiong/hulljs/commit/23089e0)) 83 | * v0.2.0 ([218cbd6](https://github.com/luoguoxiong/hulljs/commit/218cbd6)) 84 | * fix: add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b2)) 85 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 86 | * fix: eslint 缺少typescript问题 ([864a559](https://github.com/luoguoxiong/hulljs/commit/864a559)) 87 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 88 | * feat: add packages @hulljs/utils ([6a4818d](https://github.com/luoguoxiong/hulljs/commit/6a4818d)) 89 | * feat: add vue template ([05701ca](https://github.com/luoguoxiong/hulljs/commit/05701ca)) 90 | * feat: eslint for hulljs ([2648211](https://github.com/luoguoxiong/hulljs/commit/2648211)) 91 | * feat: for eslint vue ([8599835](https://github.com/luoguoxiong/hulljs/commit/8599835)) 92 | * feat: ok ([824478b](https://github.com/luoguoxiong/hulljs/commit/824478b)) 93 | * feat: test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af)) 94 | * feat: test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701c)) 95 | * feat: test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cd)) 96 | * feat: test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da)) 97 | * feat: test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c)) 98 | * feat: test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43)) 99 | * feat: test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f59250)) 100 | * chore(build): release ([fa1ac7e](https://github.com/luoguoxiong/hulljs/commit/fa1ac7e)) 101 | 102 | 103 | 104 | 105 | 106 | ## 0.1.0 (2022-07-28) 107 | 108 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 109 | 110 | 111 | 112 | 113 | 114 | ## 0.0.9 (2022-06-16) 115 | 116 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 117 | 118 | 119 | 120 | 121 | 122 | ## 0.0.8 (2022-06-12) 123 | 124 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 125 | 126 | 127 | 128 | 129 | 130 | ## 0.0.7 (2022-06-12) 131 | 132 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 133 | 134 | 135 | 136 | 137 | 138 | ## 0.0.6 (2022-06-11) 139 | 140 | * fix: eslint 缺少typescript问题 ([864a559](https://github.com/luoguoxiong/hulljs/commit/864a559)) 141 | 142 | 143 | 144 | 145 | 146 | ## 0.0.5 (2022-06-11) 147 | 148 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 149 | 150 | 151 | 152 | 153 | 154 | ## 0.0.4 (2022-06-11) 155 | 156 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 157 | 158 | 159 | 160 | 161 | 162 | ## 0.0.3 (2022-06-11) 163 | 164 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 165 | 166 | 167 | 168 | 169 | 170 | ## [0.1.0](https://github.com/luoguoxiong/hulljs/compare/v0.0.3...v0.1.0) (2022-06-11) 171 | 172 | 173 | ### 🐛 Bug Fixes | Bug 修复 174 | 175 | * add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b27e89bef094a0d7f3ade77122395a78bc0)) 176 | 177 | 178 | 179 | ## 0.1.0 (2022-06-10) 180 | 181 | 182 | ### ✨ Features | 新功能 183 | 184 | * add packages @hulljs/utils ([6a4818d](https://github.com/luoguoxiong/hulljs/commit/6a4818dfd32770136734027c866787552e496ced)) 185 | * add vue template ([05701ca](https://github.com/luoguoxiong/hulljs/commit/05701cabdc6b9dc370a00be8158a7fa993ee63b3)) 186 | * eslint for hulljs ([2648211](https://github.com/luoguoxiong/hulljs/commit/2648211c914dca03f1ceb07891b63423f2de9f37)) 187 | * for eslint vue ([8599835](https://github.com/luoguoxiong/hulljs/commit/85998357521ae4ed2542e02c907ddb9d19db4f74)) 188 | * test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af4f4a0fac7ce23bf0e3aa89e4577d9073b)) 189 | * test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701cb048f668ff4ec2d1ee1cb21e8ef87f930)) 190 | * test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cdcdbdb51c0a09f54b980e19320e94eb02c)) 191 | * test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da4ad397f984352294fd4c66e994b35a74f)) 192 | * test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c0e6d9e1fbcc37bf3a5d659978c81289b0)) 193 | * test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43edde66d27b8d1eaed0fecd65d9b812587)) 194 | * test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f592508321fab77b739d9977e293b49063fb173)) 195 | 196 | 197 | 198 | ## [0.2.0](https://github.com/luoguoxiong/hulljs/compare/v0.1.0...v0.2.0) (2022-06-10) 199 | 200 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 201 | 202 | 203 | 204 | 205 | 206 | 207 | # [0.1.0](https://github.com/projects/luoguoxiong/repos/hulljs/compare/diff?targetBranch=refs%2Ftags%2Fv0.0.1&sourceBranch=refs%2Ftags%2Fv0.1.0) (2022-06-10) 208 | 209 | **Note:** Version bump only for package @hulljs/eslint-config-hull-app 210 | -------------------------------------------------------------------------------- /packages/eslint-config-hull-app/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | 'eslint:recommended', 4 | 'plugin:@typescript-eslint/eslint-recommended', 5 | 'plugin:@typescript-eslint/recommended', 6 | ], 7 | plugins: ['prettier', '@typescript-eslint', 'import'], 8 | rules: { 9 | camelcase: 'off', 10 | '@typescript-eslint/naming-convention': [ 11 | 0, 12 | { 13 | selector: 'property', 14 | format: ['camelCase', 'PascalCase', 'UPPER_CASE'], 15 | leadingUnderscore: 'allow', 16 | }, // 强制使用驼峰、帕斯卡、常量大写命名 --CUSTOM 17 | { 18 | selector: 'interface', 19 | format: ['PascalCase'], 20 | }, 21 | { 22 | selector: 'typeAlias', 23 | format: ['PascalCase'], 24 | }, 25 | { 26 | selector: 'class', 27 | format: ['PascalCase'], 28 | }, // class和interface采用帕斯卡命名(不允许下划线) 29 | ], 30 | '@typescript-eslint/interface-name-prefix': 0, // interface命名必须以I开头 31 | 32 | // ============空格 && 缩进============= 33 | 'indent': 'off', 34 | '@typescript-eslint/indent': ['error', 2], 35 | 'eol-last': [1, 'always'], // 要求或禁止文件末尾存在空行 36 | 'func-call-spacing': [2, 'never'], // 要求或禁止在函数标识符和其调用之间有空格 37 | 'template-tag-spacing': [2, 'always'], // 要求或禁止在模板标记和它们的字面量之间有空格 38 | 'spaced-comment': [ 39 | 2, 40 | 'always', 41 | { 42 | // 要求或禁止在注释前有空白 43 | line: { 44 | markers: ['/'], 45 | exceptions: ['-', '+'], 46 | }, 47 | block: { 48 | markers: ['!'], 49 | exceptions: ['*'], 50 | balanced: true, 51 | }, 52 | }, 53 | ], 54 | 'space-infix-ops': 2, // 要求中缀操作符周围有空格 55 | 'comma-spacing': [2, { after: true }], // 强制在逗号前后使用一致的空格 56 | 'no-trailing-spaces': 2, // 禁用行尾空格 57 | 'space-before-function-paren': [2, 'never'], // 要求或禁止函数圆括号之前有一个空格 58 | 'no-multi-spaces': 2, // 禁止使用多个空格 59 | 'object-curly-spacing': [2, 'always'], // 对象大括号旁必须有空格 60 | '@typescript-eslint/type-annotation-spacing': 1, 61 | 'no-unexpected-multiline': 2, // 禁止不期待的多行写法 62 | 'operator-linebreak': [ 63 | 2, 64 | 'after', 65 | { overrides: { '?': 'before', ':': 'before' } }, 66 | ], // 过长需换行时操作符的位置 --CUSTOM 67 | 68 | // ============符号相关============= 69 | 'comma-style': [2, 'last'], // 逗号规则 70 | 'comma-dangle': [2, 'always-multiline'], // 行末尾必须有逗号 71 | 'semi-style': [2, 'last'], // 强制分号的位置 72 | semi: [2, 'always'], // 语句必须分号结尾 73 | 'jsx-quotes': [2, 'prefer-double'], // JSX元素中的字符串必须使用双引号 74 | quotes: [2, 'single'], // 字符串必须使用单引号 75 | '@typescript-eslint/member-delimiter-style': [ 76 | 2, 77 | { 78 | // interface, type内的成员末尾必须使用统一符号(逗号) 79 | multiline: { 80 | delimiter: 'semi', 81 | requireLast: true, 82 | }, 83 | singleline: { 84 | delimiter: 'semi', 85 | requireLast: false, 86 | }, 87 | }, 88 | ], 89 | eqeqeq: [2, 'smart'], // 强制使用三等,除了对比null/undefined --CUSTOM 90 | 'no-extra-parens': 0, // 禁止不必要的括号 (as any写法会被误判) 91 | 92 | // ============箭头函数相关============= 93 | 'arrow-parens': 2, // 要求箭头函数的参数使用圆括号 94 | 'no-confusing-arrow': [2, { allowParens: true }], // 禁止在可能与比较操作符相混淆的地方使用箭头函数 95 | 'arrow-spacing': [2, { before: true, after: true }], 96 | 'arrow-body-style': [2, 'as-needed'], // 要求箭头函数体使用大括号 97 | 98 | // ============其他============= 99 | 'prefer-const': 2, // 要求使用 const 声明那些声明后不再被修改的变量 100 | 'one-var-declaration-per-line': 2, // 禁止一次性定义多个变量 101 | 'key-spacing': [2, { afterColon: true }], // object的key的“:”之后至少有一个空格 102 | 'import/order': 2, // import引入按照一定顺序 103 | 'no-inner-declarations': 1, // 禁止在嵌套的块中出现变量声明或 function 声明 --CUSTOM 104 | 'require-atomic-updates': 1, // 禁止由于 await 或 yield的使用而可能导致出现竞态条件的赋值 --CUSTOM 105 | 'no-case-declarations': 1, // 不允许在 case 子句中使用词法声明 --CUSTOM 106 | 'prefer-rest-params': 0, // 要求使用剩余参数而不是 arguments --CUSTOM 107 | 'prefer-template': 1, // 要求使用模板字面量而非字符串连接 --CUSTOM 108 | '@typescript-eslint/consistent-type-assertions': 1, // 强制规范类型定义的方式 --CUSTOM 109 | '@typescript-eslint/no-this-alias': 1, // 禁止对this使用别名 --CUSTOM 110 | '@typescript-eslint/no-namespace': 1, // 禁止使用自定义TypeScript模块和名称空间 --CUSTOM 111 | '@typescript-eslint/no-unused-vars': [ 112 | 1, 113 | { vars: 'all', args: 'none', ignoreRestSiblings: true }, 114 | ], // 提示未使用的变量 --CUSTOM 115 | 'no-undef': 0, // 禁用未声明的变量,除非它们在 /*global */ 注释中被提到 (原因:全局变量较常用,定义在global.d.ts中即可) 116 | 'no-constant-condition': 0, // 禁止在条件中使用常量表达式 117 | 'prefer-spread': 0, // 要求使用扩展运算符而非 .apply() 118 | 'no-useless-escape': 0, // 禁用不必要的转义字符 (意义不大) 119 | 'dot-notation': 0, // object操作要求使用点号 (意义不大) 120 | 'no-unused-vars': 0, // 禁止出现未使用过的变量(与typescript规则重复) 121 | 'promise/always-return': 0, // promise.then必须return 122 | 'promise/no-callback-in-promise': 0, // promise.then中禁止使用回调函数 123 | '@typescript-eslint/no-var-requires': 0, // 禁止var foo = require("foo")用import代替 124 | '@typescript-eslint/explicit-function-return-type': 0, // 对返回类型不明确的函数必须声明类型 125 | '@typescript-eslint/no-non-null-assertion': 0, // 禁止使用!的非null断言后缀运算符 126 | '@typescript-eslint/no-use-before-define': 0, // 在定义变量和函数之前禁止使用 127 | '@typescript-eslint/no-explicit-any': 0, // 禁止使用any类型 128 | '@typescript-eslint/no-angle-bracket-type-assertion': 0, // 禁止使用尖括号范型 129 | '@typescript-eslint/no-empty-function': 0, 130 | '@typescript-eslint/no-inferrable-types': 0, // 不允许对初始化为数字,字符串或布尔值的变量或参数进行显式类型声明 131 | }, 132 | parserOptions: { 133 | parser: require.resolve('@typescript-eslint/parser'), 134 | extraFileExtensions: ['.vue'], 135 | ecmaFeatures: { 136 | jsx: true, 137 | }, 138 | }, 139 | overrides: [ 140 | { 141 | files: ['*.ts', '*.tsx'], 142 | rules: { 143 | 'no-unused-vars': 'off', 144 | }, 145 | }, 146 | ], 147 | }; 148 | 149 | -------------------------------------------------------------------------------- /packages/eslint-config-hull-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hulljs/eslint-config-hull-app", 3 | "version": "0.8.0", 4 | "description": "ESLint configuration used by hulljs", 5 | "files": [ 6 | "index.js", 7 | "react.js", 8 | "vue.js" 9 | ], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "@typescript-eslint/eslint-plugin": "^5.25.0", 14 | "@typescript-eslint/parser": "^5.25.0", 15 | "eslint": "^8.16.0", 16 | "eslint-plugin-import": "^2.26.0", 17 | "eslint-plugin-prettier": "^4.0.0", 18 | "eslint-plugin-react": "^7.30.0", 19 | "eslint-plugin-react-hooks": "^4.5.0", 20 | "eslint-plugin-vue": "^9.0.1", 21 | "typescript": "^4.6.4" 22 | }, 23 | "engines": { 24 | "node": ">=14.0.0" 25 | }, 26 | "publishConfig": { 27 | "access": "public" 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/eslint-config-hull-app/react.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [require.resolve('./index.js'), 'plugin:react/recommended'], 3 | 4 | plugins: ['react', 'react-hooks'], 5 | 6 | rules: { 7 | // ============React规则============= 8 | 'react/default-props-match-prop-types': 1, // 有默认值的属性必须在propTypes中指定 --CUSTOM 9 | 'react/no-array-index-key': 1, // 不要使用数组索引作为key,尽可能使用ID 10 | 'react/no-multi-comp': 1, // 一个文件只能存在一个组件 --CUSTOM 11 | 'react/no-unused-prop-types': 1, // 禁止未使用的prop参数 12 | 'react/prefer-es6-class': 1, // 强制使用es6 extend方法创建组件 13 | 'react/require-default-props': 1, // 非require的propTypes必须制定默认值 14 | 'react/self-closing-comp': 1, // 没有children的组件和html必须使用自闭和标签 15 | 'react/sort-comp': 1, // 对组件的方法排序 16 | 'react/sort-prop-types': 1, // 对prop排序 17 | 'react/style-prop-object': 1, // 组件参数如果是style,value必须是object 18 | 'react/jsx-boolean-value': 1, // 属性值为true的时候,省略值只写属性名 19 | 'react/jsx-closing-tag-location': 1, // 强制开始标签闭合标签位置 20 | 'react/jsx-equals-spacing': 1, // 属性赋值不允许有空格 21 | 'react/jsx-first-prop-new-line': 1, // 只有一个属性情况下单行 22 | 'react/jsx-key': 2, // 强制遍历出来的jsx加key 23 | 'react/jsx-max-props-per-line': [1, { maximum: 1 }], // 每行最多几个属性 24 | 'react/jsx-no-comment-textnodes': 1, // 检查jsx注释 25 | 'react/jsx-pascal-case': 1, // 检查jsx标签名规范 26 | 'react/jsx-wrap-multilines': [ 27 | 1, 28 | { 29 | declaration: 'parens-new-line', 30 | assignment: 'parens-new-line', 31 | return: 'parens-new-line', 32 | arrow: 'ignore', 33 | condition: 'ignore', 34 | logical: 'ignore', 35 | prop: 'ignore', 36 | }, 37 | ], 38 | 'react-hooks/rules-of-hooks': 2, // 检查 Hook 的规则 39 | 'react-hooks/exhaustive-deps': 0, // 检查 Effect 的依赖(autofix时会自动添加依赖,不安全,故关掉) --CUSTOM 40 | }, 41 | }; 42 | -------------------------------------------------------------------------------- /packages/eslint-config-hull-app/vue.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: [ 3 | require.resolve('./index.js'), 4 | 'plugin:vue/vue3-recommended', 5 | ], 6 | rules: { 7 | 'vue/multi-word-component-names': 'off', 8 | }, 9 | }; 10 | -------------------------------------------------------------------------------- /packages/hull-build/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | CHANGELOG.md 3 | tsconfig.json -------------------------------------------------------------------------------- /packages/hull-build/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 0.8.2 (2024-02-05) 7 | 8 | * fix: 热更新失效 ([dc70c64](https://github.com/luoguoxiong/hulljs/commit/dc70c64)) 9 | 10 | 11 | 12 | 13 | 14 | ## 0.8.1 (2024-01-04) 15 | 16 | * fix: svg no use asset ([8b6d04f](https://github.com/luoguoxiong/hulljs/commit/8b6d04f)) 17 | 18 | 19 | 20 | 21 | 22 | ## 0.8.0 (2022-11-17) 23 | 24 | * feat: change webpack cacheDirectory ([2aef1f7](https://github.com/luoguoxiong/hulljs/commit/2aef1f7)) 25 | 26 | 27 | 28 | 29 | 30 | ## 0.7.0 (2022-11-17) 31 | 32 | * feat: 添加browserslist环境区分 ([b080c06](https://github.com/luoguoxiong/hulljs/commit/b080c06)) 33 | 34 | 35 | 36 | 37 | 38 | ## 0.6.0 (2022-11-17) 39 | 40 | **Note:** Version bump only for package @hulljs/build 41 | 42 | 43 | 44 | 45 | 46 | ## 0.5.0 (2022-11-16) 47 | 48 | * feat: 升级preset ([a8eeab8](https://github.com/luoguoxiong/hulljs/commit/a8eeab8)) 49 | 50 | 51 | 52 | 53 | 54 | ## 0.4.0 (2022-11-14) 55 | 56 | * feat: extraBabelPresets for vite ([0ddac97](https://github.com/luoguoxiong/hulljs/commit/0ddac97)) 57 | 58 | 59 | 60 | 61 | 62 | ## 0.3.0 (2022-11-07) 63 | 64 | * feat: 添加codeSplitting 策略 ([c43dfbd](https://github.com/luoguoxiong/hulljs/commit/c43dfbd)) 65 | 66 | 67 | 68 | 69 | 70 | ## 0.2.0 (2022-08-31) 71 | 72 | * v0.0.1 ([abb7235](https://github.com/luoguoxiong/hulljs/commit/abb7235)) 73 | * v0.0.1 ([9741168](https://github.com/luoguoxiong/hulljs/commit/9741168)) 74 | * v0.0.1 ([fd6dff8](https://github.com/luoguoxiong/hulljs/commit/fd6dff8)) 75 | * v0.0.1 ([7bdb68f](https://github.com/luoguoxiong/hulljs/commit/7bdb68f)) 76 | * v0.0.1 ([0d7b9a0](https://github.com/luoguoxiong/hulljs/commit/0d7b9a0)) 77 | * v0.0.1 ([23a8219](https://github.com/luoguoxiong/hulljs/commit/23a8219)) 78 | * v0.0.1 ([2e7d627](https://github.com/luoguoxiong/hulljs/commit/2e7d627)) 79 | * v0.0.1-alpha.0 ([2bee034](https://github.com/luoguoxiong/hulljs/commit/2bee034)) 80 | * v0.0.1-alpha.0 ([91ec57e](https://github.com/luoguoxiong/hulljs/commit/91ec57e)) 81 | * v0.0.2 ([484bbd2](https://github.com/luoguoxiong/hulljs/commit/484bbd2)) 82 | * v0.0.2 ([93bde13](https://github.com/luoguoxiong/hulljs/commit/93bde13)) 83 | * v0.0.2 ([5869178](https://github.com/luoguoxiong/hulljs/commit/5869178)) 84 | * v0.0.2 ([c02f578](https://github.com/luoguoxiong/hulljs/commit/c02f578)) 85 | * v0.0.2-alpha.0 ([92972ca](https://github.com/luoguoxiong/hulljs/commit/92972ca)) 86 | * v0.0.4 ([64c2b6a](https://github.com/luoguoxiong/hulljs/commit/64c2b6a)) 87 | * v0.0.5 ([a332989](https://github.com/luoguoxiong/hulljs/commit/a332989)) 88 | * v0.0.6 ([45d2cdc](https://github.com/luoguoxiong/hulljs/commit/45d2cdc)) 89 | * v0.0.7 ([e4ab4fd](https://github.com/luoguoxiong/hulljs/commit/e4ab4fd)) 90 | * v0.0.8 ([b8131c9](https://github.com/luoguoxiong/hulljs/commit/b8131c9)) 91 | * v0.0.9 ([3c57a80](https://github.com/luoguoxiong/hulljs/commit/3c57a80)) 92 | * v0.1.0 ([da199ef](https://github.com/luoguoxiong/hulljs/commit/da199ef)) 93 | * v0.1.0 ([1e16cfc](https://github.com/luoguoxiong/hulljs/commit/1e16cfc)) 94 | * v0.1.0 ([9857d8a](https://github.com/luoguoxiong/hulljs/commit/9857d8a)) 95 | * v0.1.0 ([ef972e3](https://github.com/luoguoxiong/hulljs/commit/ef972e3)) 96 | * v0.1.0 ([3ac3e8b](https://github.com/luoguoxiong/hulljs/commit/3ac3e8b)) 97 | * v0.1.0 ([5e6c390](https://github.com/luoguoxiong/hulljs/commit/5e6c390)) 98 | * v0.1.0-alpha.0 ([23089e0](https://github.com/luoguoxiong/hulljs/commit/23089e0)) 99 | * v0.2.0 ([218cbd6](https://github.com/luoguoxiong/hulljs/commit/218cbd6)) 100 | * feat: 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407)) 101 | * feat: build ([e0c8bc4](https://github.com/luoguoxiong/hulljs/commit/e0c8bc4)) 102 | * feat: change defindconfig ([81fad7c](https://github.com/luoguoxiong/hulljs/commit/81fad7c)) 103 | * feat: cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6)) 104 | * feat: for vite ([2966cf9](https://github.com/luoguoxiong/hulljs/commit/2966cf9)) 105 | * feat: ok ([824478b](https://github.com/luoguoxiong/hulljs/commit/824478b)) 106 | * feat: postcss ([22c45f9](https://github.com/luoguoxiong/hulljs/commit/22c45f9)) 107 | * feat: test ([9cfc315](https://github.com/luoguoxiong/hulljs/commit/9cfc315)) 108 | * feat: test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af)) 109 | * feat: test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701c)) 110 | * feat: test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cd)) 111 | * feat: test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da)) 112 | * feat: test ([e7feada](https://github.com/luoguoxiong/hulljs/commit/e7feada)) 113 | * feat: test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c)) 114 | * feat: test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43)) 115 | * feat: test ([7126dd7](https://github.com/luoguoxiong/hulljs/commit/7126dd7)) 116 | * feat: test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f59250)) 117 | * feat: update vite version ([3fea53c](https://github.com/luoguoxiong/hulljs/commit/3fea53c)) 118 | * feat: vite complete ([12fbe4e](https://github.com/luoguoxiong/hulljs/commit/12fbe4e)) 119 | * feat: vite doing ([0e359e8](https://github.com/luoguoxiong/hulljs/commit/0e359e8)) 120 | * fix: 添加vite额外插件配置 ([1146789](https://github.com/luoguoxiong/hulljs/commit/1146789)) 121 | * fix: add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b2)) 122 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 123 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 124 | * fix: vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec72)) 125 | * chore(build): release ([fa1ac7e](https://github.com/luoguoxiong/hulljs/commit/fa1ac7e)) 126 | * docs: 完善文档 ([a4ed041](https://github.com/luoguoxiong/hulljs/commit/a4ed041)) 127 | * docs: 完善文档 ([5ffcdfc](https://github.com/luoguoxiong/hulljs/commit/5ffcdfc)) 128 | 129 | 130 | 131 | 132 | 133 | ## 0.1.0 (2022-07-28) 134 | 135 | * feat: update vite version ([3fea53c](https://github.com/luoguoxiong/hulljs/commit/3fea53c)) 136 | 137 | 138 | 139 | 140 | 141 | ## 0.0.9 (2022-06-16) 142 | 143 | * fix: 添加vite额外插件配置 ([1146789](https://github.com/luoguoxiong/hulljs/commit/1146789)) 144 | 145 | 146 | 147 | 148 | 149 | ## 0.0.8 (2022-06-12) 150 | 151 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 152 | 153 | 154 | 155 | 156 | 157 | ## 0.0.7 (2022-06-12) 158 | 159 | **Note:** Version bump only for package @hulljs/build 160 | 161 | 162 | 163 | 164 | 165 | ## 0.0.6 (2022-06-11) 166 | 167 | **Note:** Version bump only for package @hulljs/build 168 | 169 | 170 | 171 | 172 | 173 | ## 0.0.5 (2022-06-11) 174 | 175 | **Note:** Version bump only for package @hulljs/build 176 | 177 | 178 | 179 | 180 | 181 | ## 0.0.4 (2022-06-11) 182 | 183 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 184 | 185 | 186 | 187 | 188 | 189 | ## 0.0.3 (2022-06-11) 190 | 191 | **Note:** Version bump only for package @hulljs/build 192 | 193 | 194 | 195 | 196 | 197 | ## [0.1.0](https://github.com/luoguoxiong/hulljs/compare/v0.0.3...v0.1.0) (2022-06-11) 198 | 199 | 200 | ### 🐛 Bug Fixes | Bug 修复 201 | 202 | * add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b27e89bef094a0d7f3ade77122395a78bc0)) 203 | 204 | 205 | 206 | ## 0.1.0 (2022-06-10) 207 | 208 | 209 | ### 🐛 Bug Fixes | Bug 修复 210 | 211 | * vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec7273b817f76ad359cfb8e9dabbb0eed7f04)) 212 | 213 | 214 | ### 📝 Documentation | 文档 215 | 216 | * 完善文档 ([a4ed041](https://github.com/luoguoxiong/hulljs/commit/a4ed041ea0aac4fb119559ca5c898c4e5cfba2f3)) 217 | * 完善文档 ([5ffcdfc](https://github.com/luoguoxiong/hulljs/commit/5ffcdfcf0c94885c0ea05481102acc8ea765a08a)) 218 | 219 | 220 | ### ✨ Features | 新功能 221 | 222 | * 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407fcaea1153ff421c41ead174539be99b9b)) 223 | * build ([e0c8bc4](https://github.com/luoguoxiong/hulljs/commit/e0c8bc40d475ca5173fe3e86a016b89d0c59b628)) 224 | * change defindconfig ([81fad7c](https://github.com/luoguoxiong/hulljs/commit/81fad7ceaa2993bedf1a1e4d7087afbe8b2cd040)) 225 | * cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6e44439cb94d1080cc3e0ee6556271383c)) 226 | * for vite ([2966cf9](https://github.com/luoguoxiong/hulljs/commit/2966cf90503ae8aeab9227b89c8ea3ae905d2882)) 227 | * postcss ([22c45f9](https://github.com/luoguoxiong/hulljs/commit/22c45f940e35e9ee9faf5e43062210c96a8b1ef7)) 228 | * test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af4f4a0fac7ce23bf0e3aa89e4577d9073b)) 229 | * test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701cb048f668ff4ec2d1ee1cb21e8ef87f930)) 230 | * test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cdcdbdb51c0a09f54b980e19320e94eb02c)) 231 | * test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da4ad397f984352294fd4c66e994b35a74f)) 232 | * test ([e7feada](https://github.com/luoguoxiong/hulljs/commit/e7feada6206a50af9d3bf316c51d4a9613b4a7cc)) 233 | * test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c0e6d9e1fbcc37bf3a5d659978c81289b0)) 234 | * test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43edde66d27b8d1eaed0fecd65d9b812587)) 235 | * test ([7126dd7](https://github.com/luoguoxiong/hulljs/commit/7126dd70765e17e4d0c3d16ac78dc82dd7a08c0e)) 236 | * test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f592508321fab77b739d9977e293b49063fb173)) 237 | * vite complete ([12fbe4e](https://github.com/luoguoxiong/hulljs/commit/12fbe4e43d2eca8c136baeeee66b1d90a0d0604c)) 238 | * vite doing ([0e359e8](https://github.com/luoguoxiong/hulljs/commit/0e359e830031dcd14792a7ef4e3a85768b1ce11d)) 239 | 240 | 241 | 242 | ## [0.2.0](https://github.com/luoguoxiong/hulljs/compare/v0.1.0...v0.2.0) (2022-06-10) 243 | 244 | **Note:** Version bump only for package @hulljs/build 245 | 246 | 247 | 248 | 249 | 250 | 251 | # [0.1.0](https://github.com/projects/luoguoxiong/repos/hulljs/compare/diff?targetBranch=refs%2Ftags%2Fv0.0.1&sourceBranch=refs%2Ftags%2Fv0.1.0) (2022-06-10) 252 | 253 | **Note:** Version bump only for package @hulljs/build 254 | -------------------------------------------------------------------------------- /packages/hull-build/README.md: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoguoxiong/hulljs/191b09d78725afa0d40cc2d8cefacba92eff8d6c/packages/hull-build/README.md -------------------------------------------------------------------------------- /packages/hull-build/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hulljs/build", 3 | "version": "0.8.2", 4 | "description": "hull-build", 5 | "type": "commonjs", 6 | "author": "", 7 | "license": "ISC", 8 | "bin": { 9 | "hull-build": "./dist/index.js" 10 | }, 11 | "main": "./dist/index.js", 12 | "types": "./dist/index.d.js", 13 | "scripts": { 14 | "build": "tsc", 15 | "watch": "tsc -w" 16 | }, 17 | "dependencies": { 18 | "@hulljs/babel-preset-hull-app": "0.8.0", 19 | "@hulljs/utils": "0.8.0", 20 | "@hulljs/vite-plugin-babel-plugins": "0.8.0", 21 | "@hulljs/vite-plugin-html": "0.8.0", 22 | "@vitejs/plugin-legacy": "2.0.0", 23 | "@vitejs/plugin-react": "2.0.0", 24 | "@vitejs/plugin-vue": "3.0.1", 25 | "@vitejs/plugin-vue-jsx": "2.0.0", 26 | "ajv": "^8.11.0", 27 | "babel-loader": "^8.2.3", 28 | "css-loader": "^6.7.1", 29 | "css-minimizer-webpack-plugin": "^3.4.1", 30 | "html-webpack-plugin": "^5.5.0", 31 | "less": "^4.1.2", 32 | "less-loader": "^10.2.0", 33 | "mini-css-extract-plugin": "^2.6.0", 34 | "postcss": "^8.4.13", 35 | "postcss-loader": "^6.2.1", 36 | "postcss-preset-env": "^7.5.0", 37 | "resolve-url-loader": "^5.0.0", 38 | "rimraf": "^3.0.2", 39 | "rollup-plugin-visualizer": "^5.6.0", 40 | "sass": "^1.51.0", 41 | "sass-loader": "^12.6.0", 42 | "source-map-loader": "^3.0.1", 43 | "style-loader": "^3.3.1", 44 | "terser-webpack-plugin": "^5.3.1", 45 | "vite": "3.0.3", 46 | "vue": "^3.2.34", 47 | "vue-loader": "^17.0.0", 48 | "webpack": "^5.72.0", 49 | "webpack-bundle-analyzer": "^4.5.0", 50 | "webpack-dev-server": "^4.9.0", 51 | "webpack-merge": "^5.8.0", 52 | "webpackbar": "^5.0.2", 53 | "yargs-parser": "^21.0.1" 54 | }, 55 | "devDependencies": { 56 | "typescript": "^4.6.4" 57 | }, 58 | "engines": { 59 | "node": ">= 14.0.0" 60 | }, 61 | "publishConfig": { 62 | "access": "public" 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /packages/hull-build/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | <%= htmlWebpackPlugin.options.title %> 11 | 12 | 13 |
14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/hull-build/src/build/defineConfig.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import Ajv from 'ajv'; 3 | import { createConfig } from '@hulljs/utils'; 4 | import { RunBuildOpts, RequiredBuildOpts } from '../types'; 5 | 6 | export const configTool = createConfig(); 7 | 8 | const defaultConfig: RequiredBuildOpts = { 9 | appDirectory: process.cwd(), 10 | entry: path.join(process.cwd(), '/src/index'), 11 | outputPath: path.join(process.cwd(), '/build'), 12 | env: 'development', 13 | analyzer: false, 14 | buildTool: 'webpack', 15 | projectType: 'react', 16 | isProd: false, 17 | port: 8000, 18 | outputPublicPath: '/', 19 | resolveAlias: {}, 20 | shouldUseSourceMap: false, 21 | extraBabelPresets: [], 22 | fileSizeLimit: 1000, 23 | htmlPluginOpts: { 24 | template: path.resolve(__dirname, '../../public/index.html'), 25 | inject: { 26 | title: 'welcome-use-hulljs', 27 | }, 28 | }, 29 | definePluginOptions: {}, 30 | isUseBundleAnalyzer: false, 31 | devServer: { 32 | port: 8000, 33 | https: false, 34 | }, 35 | extraWebpackPlugins: [], 36 | extraModuleRules: [], 37 | splitChunks: {}, 38 | splitChunksLibary: {}, 39 | sassLoaderOptions: {}, 40 | lessLoaderOptions: {}, 41 | proxy: {}, 42 | extraBabelPlugins: [], 43 | viteExtraBuildOptions: {}, 44 | viteExtraPlugins: [], 45 | }; 46 | 47 | const schema = { 48 | type: 'object', 49 | properties: { 50 | appDirectory: { type: 'string' }, 51 | env: { type: 'string' }, 52 | port: { type: 'number' }, 53 | analyzer: { type: 'boolean' }, 54 | isProd: { type: 'boolean' }, 55 | buildTool: { 56 | type: 'string', 57 | pattern: '(webpack|vite)', 58 | }, 59 | projectType: { 60 | type: 'string', 61 | pattern: '(react|vue3)', 62 | }, 63 | entry: { type: 'string' }, 64 | outputPath: { type: 'string' }, 65 | outputPublicPath: { type: 'string' }, 66 | resolveAlias: { 67 | type: 'object', 68 | }, 69 | shouldUseSourceMap: { type: 'boolean' }, 70 | extraBabelPresets: { 71 | type: 'array', 72 | }, 73 | fileSizeLimit: { type: 'number' }, 74 | htmlPluginOpts: { 75 | type: 'object', 76 | properties: { 77 | template: { type: 'string' }, 78 | inject: { type: 'object' }, 79 | }, 80 | required: ['template'], 81 | }, 82 | definePluginOptions: { 83 | type: 'object', 84 | }, 85 | isUseBundleAnalyzer: { type: 'boolean' }, 86 | devServer: { 87 | type: 'object', 88 | properties: { 89 | port: { type: 'number' }, 90 | https: { type: 'boolean' }, 91 | }, 92 | }, 93 | extraWebpackPlugins: { 94 | type: 'array', 95 | }, 96 | extraModuleRules: { 97 | type: 'array', 98 | }, 99 | splitChunks: { 100 | type: 'object', 101 | }, 102 | splitChunksLibary: { 103 | type: 'object', 104 | }, 105 | sassLoaderOptions: { 106 | type: 'object', 107 | }, 108 | lessLoaderOptions: { 109 | type: 'object', 110 | }, 111 | proxy: { 112 | type: 'object', 113 | }, 114 | extraBabelPlugins: { 115 | type: 'array', 116 | }, 117 | viteExtraBuildOptions: { 118 | type: 'object', 119 | }, 120 | viteExtraPlugins: { 121 | type: 'array', 122 | }, 123 | }, 124 | required: ['projectType', 'entry'], 125 | additionalProperties: false, 126 | }; 127 | 128 | 129 | export const defineConfig = (opts: RunBuildOpts): RequiredBuildOpts => { 130 | 131 | const ajv = new Ajv(); 132 | 133 | const validate = ajv.compile(schema); 134 | 135 | const valid = validate(opts); 136 | 137 | if (!valid) { 138 | throw validate.errors; 139 | } 140 | const libary = opts.splitChunksLibary; 141 | 142 | // schema暂时不知该如何定义 143 | if(libary){ 144 | for(const key in libary){ 145 | if(!Array.isArray(libary[key])){ 146 | throw new Error(`splitChunksLibary.${key} mast be Array`); 147 | } 148 | for( const value of libary[key]){ 149 | if(typeof value !== 'string'){ 150 | throw new Error(`splitChunksLibary.${key} items mast be String`); 151 | } 152 | } 153 | } 154 | } 155 | 156 | const config = Object.assign(defaultConfig, opts); 157 | 158 | configTool.setConfig(config); 159 | return config; 160 | }; 161 | -------------------------------------------------------------------------------- /packages/hull-build/src/build/getLoaderConfig.ts: -------------------------------------------------------------------------------- 1 | import { IGetBabelOptions } from '@hulljs/babel-preset-hull-app'; 2 | import minCssExtract from 'mini-css-extract-plugin'; 3 | import { getExistFile } from '@hulljs/utils'; 4 | import { configTool } from './defineConfig'; 5 | 6 | interface IngetJsLoaderConfig{ 7 | isProduction: boolean; 8 | isTypeScript: boolean; 9 | } 10 | 11 | 12 | export const getFileLoaderConfig = () => { 13 | const config = configTool.getConfig(); 14 | 15 | const { fileSizeLimit = 1000 } = config; 16 | return [ 17 | { 18 | test: [/\.avif|jpe?g|png|gif$/], 19 | type: 'asset', 20 | parser: { 21 | dataUrlCondition: { 22 | maxSize: fileSizeLimit, 23 | }, 24 | }, 25 | }, 26 | { 27 | test: /\.(woff|woff2|eot|ttf|mp3|mp4)$/, 28 | exclude: /node_modules/, 29 | type: 'asset', 30 | }, 31 | ]; 32 | }; 33 | 34 | export const getJsLoaderConfig = (opts: IngetJsLoaderConfig) => { 35 | const config = configTool.getConfig(); 36 | 37 | const { appDirectory, extraBabelPlugins = [], extraBabelPresets = [], projectType } = config; 38 | const { isTypeScript, isProduction } = opts; 39 | 40 | const babelOptions: IGetBabelOptions = { 41 | isTypeScript, 42 | projectType, 43 | isProduction, 44 | }; 45 | 46 | return [ 47 | { 48 | test: /\.(js|mjs|jsx|ts|tsx)$/, 49 | include: appDirectory, 50 | exclude: /node_modules/, 51 | loader: require.resolve('babel-loader'), 52 | options: { 53 | presets: [ 54 | [ 55 | require.resolve('@hulljs/babel-preset-hull-app'), 56 | babelOptions, 57 | ], 58 | ...extraBabelPresets, 59 | ], 60 | plugins: extraBabelPlugins, 61 | babelrc: false, 62 | configFile: false, 63 | cacheDirectory: true, 64 | compact: true, 65 | }, 66 | }, 67 | ]; 68 | 69 | }; 70 | 71 | export const getCssLoaderConfig = () => { 72 | const config = configTool.getConfig(); 73 | 74 | const { env, shouldUseSourceMap = false, appDirectory, sassLoaderOptions = {}, lessLoaderOptions = {} } = config; 75 | 76 | const isProduction = (env || '').includes('prod'); 77 | 78 | const isUseSourceMap = isProduction ? shouldUseSourceMap : false; 79 | 80 | const { isOk, absFilePath } = getExistFile({ appDirectory, files: ['postcss.config.js', 'postcss.config.cjs'] }); 81 | 82 | const defaultLessOpts = { 83 | lessOptions: { 84 | javascriptEnabled: true, 85 | }, 86 | }; 87 | 88 | const defaultSassOpts = {}; 89 | const getStyleLoaders = (isCssModule: boolean, otherCssLoader?: string, otherLoaderOpts?: any) => { 90 | const loaders: any[] = [ 91 | isProduction ? minCssExtract.loader : require.resolve('style-loader'), 92 | { 93 | loader: require.resolve('css-loader'), 94 | options: { 95 | modules: isCssModule, 96 | sourceMap: isUseSourceMap, 97 | }, 98 | }, 99 | { 100 | loader: require.resolve('postcss-loader'), 101 | options: { 102 | postcssOptions: { 103 | config: isOk ? absFilePath : false, 104 | plugins: [ 105 | [ 106 | require.resolve('postcss-preset-env'), 107 | { 108 | autoprefixer: { 109 | flexbox: 'no-2009', 110 | }, 111 | stage: 3 }, 112 | ], 113 | ], 114 | }, 115 | sourceMap: isUseSourceMap, 116 | }, 117 | }, 118 | ]; 119 | if (otherCssLoader) { 120 | loaders.push( 121 | { 122 | loader: require.resolve('resolve-url-loader'), 123 | options: { 124 | root: appDirectory, 125 | }, 126 | }, 127 | { 128 | loader: require.resolve(otherCssLoader), 129 | options: { 130 | sourceMap: true, 131 | ...otherLoaderOpts, 132 | }, 133 | }, 134 | ); 135 | } 136 | return loaders; 137 | }; 138 | return [ 139 | { 140 | test: /\.css$/, 141 | exclude: /\.module.css$/, 142 | use: getStyleLoaders(false), 143 | sideEffects: true, 144 | }, 145 | { 146 | test: /\.module.css$/, 147 | use: getStyleLoaders(true), 148 | }, 149 | { 150 | test: /\.less$/, 151 | exclude: /\.module\.less$/, 152 | use: getStyleLoaders(false, 'less-loader', { 153 | ...defaultLessOpts, 154 | ...lessLoaderOptions, 155 | }), 156 | sideEffects: true, 157 | }, 158 | { 159 | test: /\.module\.less$/, 160 | use: getStyleLoaders(true, 'less-loader', { 161 | ...defaultLessOpts, 162 | ...lessLoaderOptions, 163 | }), 164 | }, 165 | { 166 | test: /\.(sass|scss)$/, 167 | exclude: /\.module\.(sass|scss)$/, 168 | use: getStyleLoaders(false, 'sass-loader', { 169 | ...defaultSassOpts, 170 | ...sassLoaderOptions, 171 | }), 172 | sideEffects: true, 173 | }, 174 | { 175 | test: /\.module\.(sass|scss)$/, 176 | use: getStyleLoaders(true, 'sass-loader', { 177 | ...defaultSassOpts, 178 | ...sassLoaderOptions, 179 | }), 180 | }, 181 | ]; 182 | }; 183 | -------------------------------------------------------------------------------- /packages/hull-build/src/build/getViteConfig.ts: -------------------------------------------------------------------------------- 1 | 2 | import path from 'path'; 3 | import{ getModulesFromConfig, getExistFile } from '@hulljs/utils'; 4 | import reactRefresh from '@vitejs/plugin-react'; 5 | import { visualizer } from 'rollup-plugin-visualizer'; 6 | import legacy from '@vitejs/plugin-legacy'; 7 | import { createHtmlPlugin } from '@hulljs/vite-plugin-html'; 8 | import viteBabelPlugins from '@hulljs/vite-plugin-babel-plugins'; 9 | import vueJsx from '@vitejs/plugin-vue-jsx'; 10 | import vue from '@vitejs/plugin-vue'; 11 | import postcssPreset from 'postcss-preset-env'; 12 | import { DevServer } from '../types'; 13 | import { configTool } from './defineConfig'; 14 | export const getViteConfig = (): any => { 15 | const buildConfig = configTool.getConfig(); 16 | 17 | const { appDirectory, lessLoaderOptions, sassLoaderOptions, 18 | shouldUseSourceMap, fileSizeLimit, projectType, isUseBundleAnalyzer, 19 | viteExtraBuildOptions, proxy, htmlPluginOpts, extraBabelPlugins, extraBabelPresets, isProd, viteExtraPlugins } = buildConfig; 20 | 21 | const { alias } = getModulesFromConfig(appDirectory); 22 | 23 | const isUseSourceMap = isProd ? shouldUseSourceMap : false; 24 | 25 | const devServer = buildConfig.devServer as DevServer; 26 | 27 | const { isOk, absFilePath } = getExistFile({ appDirectory, files: ['postcss.config.js', 'postcss.config.cjs'] }); 28 | 29 | const postcssPlugins = []; 30 | 31 | if(isOk){ 32 | const plugin = require(absFilePath).plugins || []; 33 | postcssPlugins.push(...plugin); 34 | } 35 | 36 | const projectPlugins = projectType === 'react' 37 | ? [ reactRefresh() ] 38 | : [ 39 | vueJsx({}), 40 | vue({}), 41 | ] ; 42 | return { 43 | root: buildConfig.appDirectory, 44 | base: buildConfig.outputPublicPath, 45 | define: buildConfig.definePluginOptions, 46 | mode: isProd ? 'production' : 'development', 47 | publicDir: false, 48 | plugins: [ 49 | createHtmlPlugin({ 50 | minify: isProd, 51 | entry: buildConfig.entry, 52 | template: htmlPluginOpts ? htmlPluginOpts.template : '', 53 | inject: htmlPluginOpts.inject, 54 | }), 55 | ...projectPlugins, 56 | legacy(), 57 | viteBabelPlugins( 58 | extraBabelPlugins || [], 59 | extraBabelPresets || [], 60 | ), 61 | viteExtraPlugins, 62 | ], 63 | resolve: { 64 | alias, 65 | extensions: [ 66 | '.web.mjs', 67 | '.mjs', 68 | '.web.ts', 69 | '.ts', 70 | '.web.tsx', 71 | '.tsx', 72 | '.json', 73 | '.web.js', 74 | '.js', 75 | '.web.jsx', 76 | '.jsx', 77 | ], 78 | }, 79 | css: { 80 | modules: { 81 | generateScopedName: '[name]__[local]___[hash:base64:5]', 82 | }, 83 | preprocessorOptions: { 84 | less: { 85 | javascriptEnabled: true, 86 | ...lessLoaderOptions, 87 | }, 88 | scss: { 89 | ...sassLoaderOptions, 90 | }, 91 | sass: { 92 | ...sassLoaderOptions, 93 | }, 94 | }, 95 | postcss: { 96 | plugins: [ 97 | postcssPreset({ 98 | autoprefixer: { 99 | flexbox: 'no-2009', 100 | }, 101 | stage: 3, 102 | }), 103 | ...postcssPlugins, 104 | ], 105 | }, 106 | devSourcemap: isUseSourceMap, 107 | }, 108 | cacheDir: path.resolve(appDirectory, 'node_modules/.hull_vite'), 109 | build: { 110 | ...viteExtraBuildOptions, 111 | outDir: buildConfig.outputPath, 112 | assetsInlineLimit: fileSizeLimit, 113 | rollupOptions: { 114 | plugins: [ 115 | ...( 116 | isUseBundleAnalyzer ? [ visualizer({ 117 | filename: path.resolve(appDirectory, './visualizer.html'), 118 | brotliSize: true, 119 | gzipSize: true, 120 | open: true, 121 | })] : [] 122 | ), 123 | ], 124 | }, 125 | sourcemap: isProd ? isUseSourceMap : 'inline', 126 | assetsDir: 'static', 127 | }, 128 | server: { 129 | port: devServer.port, 130 | https: devServer.https, 131 | host: true, 132 | open: true, 133 | proxy, 134 | }, 135 | }; 136 | }; 137 | -------------------------------------------------------------------------------- /packages/hull-build/src/build/getWebpackConfig.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import webpack, { Configuration } from 'webpack'; 3 | import { merge } from 'webpack-merge'; 4 | import HtmlWebpackPlugin from 'html-webpack-plugin'; 5 | import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; 6 | import { VueLoaderPlugin } from 'vue-loader'; 7 | import{ getModulesFromConfig } from '@hulljs/utils'; 8 | import { WEBPACK_COMMON_CONF, WEBPACK_DEV_CONF, WEBPACK_PROD_CONF } from '../constants'; 9 | import { createGranlarChunks } from '../features/codeSplitting'; 10 | import { getFileLoaderConfig, getJsLoaderConfig, getCssLoaderConfig } from './getLoaderConfig'; 11 | import { configTool } from './defineConfig'; 12 | 13 | export const getWebpackConfig = async(): Promise => { 14 | const buildConfig = configTool.getConfig(); 15 | 16 | const { appDirectory, shouldUseSourceMap, outputPath, 17 | outputPublicPath, resolveAlias, entry, htmlPluginOpts, 18 | extraWebpackPlugins, extraModuleRules, projectType, 19 | definePluginOptions, isUseBundleAnalyzer, splitChunks, splitChunksLibary, isProd } = buildConfig; 20 | 21 | const { modules, alias, isTypeScript } = getModulesFromConfig(appDirectory); 22 | 23 | const isUseSourceMap = isProd ? shouldUseSourceMap : false; 24 | 25 | const devtool = isProd ? (shouldUseSourceMap ? 'source-map' : false) : 'cheap-module-source-map'; 26 | 27 | const splitChunksOpts = { 28 | ...splitChunks, 29 | cacheGroups: { 30 | ...splitChunks.cacheGroups || {}, 31 | ...createGranlarChunks(splitChunksLibary), 32 | }, 33 | }; 34 | 35 | const config: Configuration = { 36 | devtool, 37 | context: appDirectory, 38 | entry, 39 | output: { 40 | path: outputPath, 41 | publicPath: outputPublicPath, 42 | }, 43 | cache: { 44 | type: 'filesystem', 45 | buildDependencies: { 46 | config: [__filename], 47 | }, 48 | cacheDirectory: path.resolve(appDirectory, 'node_modules/.cache'), 49 | }, 50 | resolve: { 51 | modules, 52 | alias: { 53 | ...resolveAlias, 54 | ...alias, 55 | }, 56 | }, 57 | optimization: { 58 | splitChunks: isProd ? splitChunksOpts : {}, 59 | }, 60 | module: { 61 | strictExportPresence: true, 62 | rules: [ 63 | ...(isUseSourceMap ? [{ 64 | exclude: /@babel(?:\/|\\{1,2})runtime/, 65 | test: /\.(js|mjs|jsx|ts|tsx|css)$/, 66 | use: ['source-map-loader'], 67 | }] : []), 68 | { 69 | test: /\.vue$/, 70 | loader: 'vue-loader', 71 | }, 72 | ...getFileLoaderConfig(), 73 | ...getJsLoaderConfig({ isTypeScript, isProduction: isProd }), 74 | ...getCssLoaderConfig(), 75 | ...(extraModuleRules ? extraModuleRules : []), 76 | ], 77 | }, 78 | plugins: [ 79 | ...(projectType === 'vue3' ? [new VueLoaderPlugin()] : []), 80 | new HtmlWebpackPlugin({ 81 | filename: 'index.html', 82 | cache: false, 83 | minify: isProd, 84 | template: htmlPluginOpts.template || path.join(__dirname, '../../public/index.html'), 85 | ...htmlPluginOpts.inject, 86 | }), 87 | new webpack.DefinePlugin({ 88 | ...definePluginOptions, 89 | 'DEBUG': !isProd, 90 | }), 91 | ...(isUseBundleAnalyzer && isProd ? [new BundleAnalyzerPlugin({ 92 | analyzerMode: 'static', 93 | reportFilename: path.resolve(appDirectory, './visualizer.html'), 94 | })] : []), 95 | ...(extraWebpackPlugins ? extraWebpackPlugins : []), 96 | ], 97 | }; 98 | 99 | return merge(isProd ? WEBPACK_PROD_CONF : WEBPACK_DEV_CONF, WEBPACK_COMMON_CONF, config); 100 | }; 101 | -------------------------------------------------------------------------------- /packages/hull-build/src/build/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import { log, getFileExport } from '@hulljs/utils'; 3 | import { IBuildOptions, RunBuildOpts, IngetUserConfigRe } from '../types'; 4 | import { CONFIG_FILES } from '../constants'; 5 | import { getWebpackConfig } from './getWebpackConfig'; 6 | import { getViteConfig } from './getViteConfig'; 7 | import * as webpackDo from './webpackAction'; 8 | import * as viteDo from './viteAction'; 9 | import { defineConfig } from './defineConfig'; 10 | 11 | type CITYPE = 'dev'| 'build' | 'server' 12 | 13 | const build = async(opts: IBuildOptions, ciType: CITYPE) => { 14 | try { 15 | const { appDirectory, env, analyzer, port } = opts; 16 | process.env.NODE_ENV = env; 17 | 18 | const configFnOrObj = await getFileExport(appDirectory, CONFIG_FILES); 19 | 20 | let config; 21 | if(typeof configFnOrObj === 'function'){ 22 | const resConf = configFnOrObj(env); 23 | config = resConf; 24 | } else if(typeof configFnOrObj === 'object'){ 25 | config = configFnOrObj; 26 | }else{ 27 | log.error('hull.conf export is a funtion or object!'); 28 | return; 29 | } 30 | 31 | const buildOpts: RunBuildOpts = { 32 | ...opts, 33 | ...config, 34 | buildTool: opts.buildTool || config.buildTool || 'webpack', 35 | isUseBundleAnalyzer: (analyzer || config.isUseBundleAnalyzer), 36 | devServer: { 37 | port: port || (config.devServer || {}).port || 8080, 38 | https: !!(config.devServer || {}).https, 39 | }, 40 | isProd: env.includes('prod'), 41 | }; 42 | 43 | 44 | const defindBuildOpts = defineConfig(buildOpts); 45 | 46 | if(buildOpts.buildTool === 'webpack'){ 47 | const webpackConf = await getWebpackConfig(); 48 | switch (ciType){ 49 | case 'dev': await webpackDo.startDevServer(webpackConf, defindBuildOpts);break; 50 | case 'build': await webpackDo.startBuildPro(webpackConf, defindBuildOpts);break; 51 | case 'server':await webpackDo.startProServer(webpackConf, defindBuildOpts);break; 52 | default: return; 53 | } 54 | }else{ 55 | const viteConf = await getViteConfig(); 56 | switch (ciType){ 57 | case 'dev': await viteDo.startDevServer(viteConf, defindBuildOpts);break; 58 | case 'build': await viteDo.startBuildPro(viteConf);break; 59 | case 'server':await viteDo.startProServer(viteConf, defindBuildOpts);break; 60 | default: return; 61 | } 62 | } 63 | } catch (error: any) { 64 | console.log(error); 65 | throw Error(error); 66 | } 67 | }; 68 | 69 | export default build; 70 | -------------------------------------------------------------------------------- /packages/hull-build/src/build/viteAction.ts: -------------------------------------------------------------------------------- 1 | import { build, createServer } from 'vite'; 2 | import { startStaticServer } from '@hulljs/utils'; 3 | import { log, choosePort } from '@hulljs/utils'; 4 | import { RequiredBuildOpts, ViteConfig } from '../types'; 5 | export const startDevServer = async(viteConfig: ViteConfig, buildOpts: RequiredBuildOpts) => { 6 | const port = await choosePort(buildOpts.devServer.port); 7 | const server = await createServer(viteConfig); 8 | await server.listen(port); 9 | log.success(`you service is running at http${buildOpts.devServer.https ? 's' : ''}://localhost:${port}`); 10 | }; 11 | 12 | 13 | export const startBuildPro = async(viteConfig: ViteConfig) => { 14 | log.msg('vite building for production...'); 15 | await build(viteConfig); 16 | log.success('vite build complete.\n'); 17 | }; 18 | 19 | 20 | export const startProServer = async(viteConfig: ViteConfig, buildOpts: RequiredBuildOpts) => { 21 | await startBuildPro(viteConfig); 22 | 23 | const port = await choosePort(buildOpts.devServer.port); 24 | startStaticServer({ 25 | assetsRoot: buildOpts.outputPath, 26 | port, 27 | isUseGzip: true, 28 | maxAge: 24 * 60 * 60 * 1000 * 360, 29 | }); 30 | }; 31 | -------------------------------------------------------------------------------- /packages/hull-build/src/build/webpackAction.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import WebpackDevServer from 'webpack-dev-server'; 3 | import webpack, { Configuration } from 'webpack'; 4 | import rm from 'rimraf'; 5 | import { choosePort, log, startStaticServer } from '@hulljs/utils'; 6 | import { DevServer, RequiredBuildOpts } from '../types'; 7 | 8 | 9 | export const startDevServer = async(webpackConfig: Configuration, buildOpts: RequiredBuildOpts) => { 10 | try { 11 | const compiler = webpack(webpackConfig); 12 | 13 | const devServer = buildOpts.devServer as DevServer; 14 | 15 | const port = await choosePort(devServer.port); 16 | 17 | const config: WebpackDevServer.Configuration = { 18 | headers: { 19 | 'Access-Control-Allow-Origin': '*', 20 | 'Access-Control-Allow-Methods': '*', 21 | 'Access-Control-Allow-Headers': '*', 22 | }, 23 | liveReload: true, 24 | hot: false, 25 | allowedHosts: 'all', 26 | historyApiFallback: true, 27 | open: true, 28 | proxy: buildOpts.proxy, 29 | port, 30 | https: devServer.https, 31 | }; 32 | 33 | const devService = new WebpackDevServer(config, compiler); 34 | 35 | await devService.start(); 36 | log.success(`you service is running at http${buildOpts.devServer.https ? 's' : ''}://localhost:${port}`); 37 | } catch (error: any) { 38 | throw Error(error); 39 | } 40 | }; 41 | 42 | export const startBuildPro = async(webpackConfig: Configuration, buildOpts: RequiredBuildOpts, callback?: any) => { 43 | log.msg('webpack building for production...'); 44 | rm( 45 | buildOpts.outputPath, 46 | (err: any) => { 47 | if (err) throw err; 48 | webpack(webpackConfig, (err, stats) => { 49 | if (err) throw err; 50 | process.stdout.write( 51 | `${stats && stats.toString({ 52 | colors: true, 53 | modules: false, 54 | children: true, 55 | chunks: false, 56 | chunkModules: false, 57 | }) }\n\n`, 58 | ); 59 | if (stats && stats.hasErrors()) { 60 | log.error('Build failed with errors.\n'); 61 | process.exit(1); 62 | } 63 | log.success('Webpack build complete.\n'); 64 | callback && callback(); 65 | }); 66 | }, 67 | ); 68 | }; 69 | 70 | export const startProServer = async(webpackConfig: Configuration, buildOpts: RequiredBuildOpts) => { 71 | const port = await choosePort(buildOpts.devServer.port); 72 | const runServer = () => { 73 | startStaticServer({ 74 | assetsRoot: buildOpts.outputPath, 75 | port, 76 | isUseGzip: true, 77 | maxAge: 24 * 60 * 60 * 1000 * 360, 78 | }); 79 | }; 80 | await startBuildPro(webpackConfig, buildOpts, runServer); 81 | }; 82 | 83 | -------------------------------------------------------------------------------- /packages/hull-build/src/constants/index.ts: -------------------------------------------------------------------------------- 1 | export { WEBPACK_DEV_CONF } from './webpack.dev.conf'; 2 | export { WEBPACK_PROD_CONF } from './webpack.prod.conf'; 3 | export { WEBPACK_COMMON_CONF } from './webpack.common.conf'; 4 | 5 | export const CONFIG_FILES = [ 6 | 'hull.conf.js', 7 | 'hull.conf.ts', 8 | ]; 9 | -------------------------------------------------------------------------------- /packages/hull-build/src/constants/webpack.common.conf.ts: -------------------------------------------------------------------------------- 1 | import webpack, { Configuration } from 'webpack'; 2 | import WebpackBar from 'webpackbar'; 3 | export const WEBPACK_COMMON_CONF: Configuration = { 4 | target: 'web', 5 | infrastructureLogging: { 6 | level: 'none', 7 | }, 8 | watchOptions: { 9 | poll: 1000, 10 | }, 11 | resolve: { 12 | extensions: [ 13 | '.web.mjs', 14 | '.mjs', 15 | '.web.ts', 16 | '.ts', 17 | '.web.tsx', 18 | '.tsx', 19 | '.json', 20 | '.web.js', 21 | '.js', 22 | '.web.jsx', 23 | '.jsx', 24 | ], 25 | }, 26 | module: { 27 | strictExportPresence: true, 28 | rules: [], 29 | }, 30 | plugins: [ 31 | new WebpackBar(), 32 | new webpack.IgnorePlugin({ 33 | resourceRegExp: /^\.\/locale$/, 34 | contextRegExp: /moment$/, 35 | }), 36 | ], 37 | }; 38 | -------------------------------------------------------------------------------- /packages/hull-build/src/constants/webpack.dev.conf.ts: -------------------------------------------------------------------------------- 1 | import { Configuration } from 'webpack'; 2 | export const WEBPACK_DEV_CONF: Configuration = { 3 | mode: 'development', 4 | 'stats': 'errors-only', 5 | output: { 6 | filename: 'static/js/bundle.js', 7 | chunkFilename: 'static/js/[name].chunk.js', 8 | assetModuleFilename: 'static/media/[name].[hash][ext]', 9 | }, 10 | plugins: [], 11 | }; 12 | -------------------------------------------------------------------------------- /packages/hull-build/src/constants/webpack.prod.conf.ts: -------------------------------------------------------------------------------- 1 | import { Configuration } from 'webpack'; 2 | import TerserPlugin from 'terser-webpack-plugin'; 3 | import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'; 4 | import MiniCssExtractPlugin from 'mini-css-extract-plugin'; 5 | 6 | export const WEBPACK_PROD_CONF: Configuration = { 7 | mode: 'production', 8 | bail: true, 9 | output: { 10 | filename: 'static/js/[name].[contenthash:8].js', 11 | chunkFilename: 'static/js/[name].[contenthash:8].chunk.js', 12 | assetModuleFilename: 'static/media/[name].[hash][ext]', 13 | }, 14 | optimization: { 15 | minimize: true, 16 | minimizer: [ 17 | new TerserPlugin({ 18 | terserOptions: { 19 | parse: { 20 | ecma: 5, 21 | }, 22 | compress: { 23 | ecma: 5, 24 | comparisons: false, 25 | inline: 2, 26 | drop_console: true, 27 | drop_debugger: true, 28 | }, 29 | mangle: { 30 | safari10: true, 31 | }, 32 | output: { 33 | ecma: 5, 34 | comments: false, 35 | ascii_only: true, 36 | }, 37 | }, 38 | }), 39 | new CssMinimizerPlugin(), 40 | ], 41 | }, 42 | plugins: [ 43 | new MiniCssExtractPlugin({ 44 | filename: 'static/css/[name].[contenthash:8].css', 45 | chunkFilename: 'static/css/[name].[contenthash:8].chunk.css', 46 | }), 47 | ], 48 | }; 49 | -------------------------------------------------------------------------------- /packages/hull-build/src/features/codeSplitting.ts: -------------------------------------------------------------------------------- 1 | const createGranlarChunks = (library: Record>) => { 2 | const cacheGroups: Record = {}; 3 | for(const libraryName in library){ 4 | const packages = library[libraryName]; 5 | cacheGroups[libraryName] = { 6 | name: libraryName, 7 | chunks: 'all', 8 | test: new RegExp( 9 | `[\\\\/]node_modules[\\\\/](${packages.join( 10 | '|', 11 | )})[\\\\/]`, 12 | ), 13 | priority: 40, 14 | enforce: true, 15 | }; 16 | } 17 | return { 18 | default: false, 19 | defaultVendors: false, 20 | ...cacheGroups, 21 | }; 22 | }; 23 | 24 | export { createGranlarChunks }; 25 | -------------------------------------------------------------------------------- /packages/hull-build/src/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'source-map-loader' 2 | declare module 'webpack-bundle-analyzer' 3 | declare module 'rimraf' 4 | declare module 'koa-static' 5 | declare module 'webpackbar' 6 | declare module 'postcss-preset-env' 7 | -------------------------------------------------------------------------------- /packages/hull-build/src/index.ts: -------------------------------------------------------------------------------- 1 | import build from './build'; 2 | import { IBuildOptions, BuildConfig } from './types'; 3 | 4 | export { BuildConfig, IBuildOptions }; 5 | 6 | export { build }; 7 | 8 | export type CliIn = {vite: boolean} & IBuildOptions 9 | 10 | -------------------------------------------------------------------------------- /packages/hull-build/src/types/index.ts: -------------------------------------------------------------------------------- 1 | import { WebpackPluginInstance, RuleSetRule } from 'webpack'; 2 | import { UserConfig, BuildOptions, PluginOption } from 'vite'; 3 | 4 | type ViteExtraBuildOptions = Omit; 5 | 6 | export type ENV = 'development' | 'production' | string 7 | 8 | export type ProjectType = 'react' | 'vue3'; 9 | 10 | export type RunBuildOpts = IBuildOptions & BuildConfig 11 | 12 | export type RequiredBuildOpts = Required 13 | 14 | export interface DevServer{ 15 | port: number; 16 | https?: boolean; 17 | } 18 | 19 | /** 构建参数配置 */ 20 | export interface IBuildOptions{ 21 | /** 工作目录 */ 22 | appDirectory: string; 23 | /** 环境变量 */ 24 | env: ENV; 25 | /** port 服务端口号 */ 26 | port?: number | string | any; 27 | /** 是否使用BundleAnalyzer打包分析器 */ 28 | analyzer?: boolean; 29 | /** 是否是生产环境 */ 30 | isProd?: boolean; 31 | /** 构建工具 */ 32 | buildTool?: 'webpack'|'vite'; 33 | } 34 | 35 | /** 自定义Webpack配置 */ 36 | export interface BuildConfig { 37 | /** 构建工具 */ 38 | buildTool?: 'webpack'|'vite'; 39 | /** 项目类型 react、vue3 */ 40 | projectType: ProjectType; 41 | /** entry */ 42 | entry: string; 43 | /** output.path */ 44 | outputPath?: string; 45 | /** output.publicPath */ 46 | outputPublicPath?: string; 47 | /** resolve.alias */ 48 | resolveAlias?: Record; 49 | /** 是否使用SourceMap */ 50 | shouldUseSourceMap?: boolean; 51 | /** 额外的babel Presets */ 52 | extraBabelPresets?: any[]; 53 | /** fileSizeLimit 静态资源压缩为base64的大小限制 */ 54 | fileSizeLimit?: number; 55 | /** html模板配置 */ 56 | htmlPluginOpts?: { 57 | /** html模板路径 */ 58 | template: string; 59 | /** html 模板插入数据 */ 60 | inject?: Record; 61 | }; 62 | /** webpackDefinePluginOptions */ 63 | definePluginOptions?: Record; 64 | /** 是否使用BundleAnalyzer打包分析器 */ 65 | isUseBundleAnalyzer?: boolean; 66 | /** WebpackDevServer 配置 */ 67 | devServer?: DevServer; 68 | /** extraWebpackPlugins */ 69 | extraWebpackPlugins?: WebpackPluginInstance[]; 70 | /** extraModuleRules */ 71 | extraModuleRules?: RuleSetRule[]; 72 | /** splitChunks */ 73 | splitChunks?: any; 74 | /** splitChunksLibary 对node_modules分包 */ 75 | splitChunksLibary?: Record>; 76 | sassLoaderOptions?: any; 77 | lessLoaderOptions?: any; 78 | proxy?: Record; 79 | /** 额外的babel pugin */ 80 | extraBabelPlugins?: any[]; 81 | /** vite其他构建参数 */ 82 | viteExtraBuildOptions?: ViteExtraBuildOptions; 83 | /** vite其他插件 */ 84 | viteExtraPlugins?: PluginOption; 85 | } 86 | 87 | export type IngetUserConfigRe = Promise<(env: ENV) => BuildConfig | BuildConfig> 88 | 89 | export type ViteConfig = UserConfig 90 | 91 | -------------------------------------------------------------------------------- /packages/hull-build/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "sourceMap": true, 8 | "resolveJsonModule": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "skipDefaultLibCheck": false, 12 | "declaration": true, 13 | "outDir": "./dist", 14 | "rootDir": "./src", 15 | "baseUrl": ".", 16 | "paths": { 17 | "@/*": ["./*"] 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/hull-cli/.npmignore: -------------------------------------------------------------------------------- 1 | ./src 2 | CHANGELOG.md 3 | ./tsconfig.json -------------------------------------------------------------------------------- /packages/hull-cli/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 0.8.2 (2024-02-05) 7 | 8 | * fix: 热更新失效 ([dc70c64](https://github.com/luoguoxiong/hulljs/commit/dc70c64)) 9 | 10 | 11 | 12 | 13 | 14 | ## 0.8.1 (2024-01-04) 15 | 16 | **Note:** Version bump only for package @hulljs/cli 17 | 18 | 19 | 20 | 21 | 22 | ## 0.8.0 (2022-11-17) 23 | 24 | **Note:** Version bump only for package @hulljs/cli 25 | 26 | 27 | 28 | 29 | 30 | ## 0.7.0 (2022-11-17) 31 | 32 | * feat: 添加browserslist环境区分 ([b080c06](https://github.com/luoguoxiong/hulljs/commit/b080c06)) 33 | 34 | 35 | 36 | 37 | 38 | ## 0.6.0 (2022-11-17) 39 | 40 | **Note:** Version bump only for package @hulljs/cli 41 | 42 | 43 | 44 | 45 | 46 | ## 0.5.0 (2022-11-16) 47 | 48 | **Note:** Version bump only for package @hulljs/cli 49 | 50 | 51 | 52 | 53 | 54 | ## 0.4.2 (2022-11-15) 55 | 56 | * fix: 修复cli init 模板 版本号问题 ([81329ca](https://github.com/luoguoxiong/hulljs/commit/81329ca)) 57 | 58 | 59 | 60 | 61 | 62 | ## 0.4.1 (2022-11-15) 63 | 64 | * fix: cli init template default version ([b3e94db](https://github.com/luoguoxiong/hulljs/commit/b3e94db)) 65 | 66 | 67 | 68 | 69 | 70 | ## 0.4.0 (2022-11-14) 71 | 72 | **Note:** Version bump only for package @hulljs/cli 73 | 74 | 75 | 76 | 77 | 78 | ## 0.3.0 (2022-11-07) 79 | 80 | * feat: 添加codeSplitting 策略 ([c43dfbd](https://github.com/luoguoxiong/hulljs/commit/c43dfbd)) 81 | 82 | 83 | 84 | 85 | 86 | ## 0.2.1 (2022-10-08) 87 | 88 | * fix: check node version before use cli ([4da7099](https://github.com/luoguoxiong/hulljs/commit/4da7099)) 89 | 90 | 91 | 92 | 93 | 94 | ## 0.2.0 (2022-08-31) 95 | 96 | * fix: 添加vite额外插件配置 ([1146789](https://github.com/luoguoxiong/hulljs/commit/1146789)) 97 | * fix: 优化cli template ([7e42ac4](https://github.com/luoguoxiong/hulljs/commit/7e42ac4)) 98 | * fix: add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b2)) 99 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 100 | * fix: cli log ([8dfb859](https://github.com/luoguoxiong/hulljs/commit/8dfb859)) 101 | * fix: cli release ([7ef199d](https://github.com/luoguoxiong/hulljs/commit/7ef199d)) 102 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 103 | * fix: test ([cc9ab8b](https://github.com/luoguoxiong/hulljs/commit/cc9ab8b)) 104 | * fix: test ([a3bb52a](https://github.com/luoguoxiong/hulljs/commit/a3bb52a)) 105 | * fix: update cli template npm ignore ([ea0fbf7](https://github.com/luoguoxiong/hulljs/commit/ea0fbf7)) 106 | * fix: update template version ([ba1e9dc](https://github.com/luoguoxiong/hulljs/commit/ba1e9dc)) 107 | * fix: vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec72)) 108 | * feat!: send an email ([c2493c5](https://github.com/luoguoxiong/hulljs/commit/c2493c5)) 109 | * v0.0.1 ([abb7235](https://github.com/luoguoxiong/hulljs/commit/abb7235)) 110 | * v0.0.1 ([9741168](https://github.com/luoguoxiong/hulljs/commit/9741168)) 111 | * v0.0.1 ([fd6dff8](https://github.com/luoguoxiong/hulljs/commit/fd6dff8)) 112 | * v0.0.1 ([7bdb68f](https://github.com/luoguoxiong/hulljs/commit/7bdb68f)) 113 | * v0.0.1 ([0d7b9a0](https://github.com/luoguoxiong/hulljs/commit/0d7b9a0)) 114 | * v0.0.1 ([23a8219](https://github.com/luoguoxiong/hulljs/commit/23a8219)) 115 | * v0.0.1 ([2e7d627](https://github.com/luoguoxiong/hulljs/commit/2e7d627)) 116 | * v0.0.1-alpha.0 ([2bee034](https://github.com/luoguoxiong/hulljs/commit/2bee034)) 117 | * v0.0.1-alpha.0 ([91ec57e](https://github.com/luoguoxiong/hulljs/commit/91ec57e)) 118 | * v0.0.2 ([484bbd2](https://github.com/luoguoxiong/hulljs/commit/484bbd2)) 119 | * v0.0.2 ([93bde13](https://github.com/luoguoxiong/hulljs/commit/93bde13)) 120 | * v0.0.2 ([5869178](https://github.com/luoguoxiong/hulljs/commit/5869178)) 121 | * v0.0.2 ([c02f578](https://github.com/luoguoxiong/hulljs/commit/c02f578)) 122 | * v0.0.2-alpha.0 ([92972ca](https://github.com/luoguoxiong/hulljs/commit/92972ca)) 123 | * v0.0.4 ([64c2b6a](https://github.com/luoguoxiong/hulljs/commit/64c2b6a)) 124 | * v0.0.5 ([a332989](https://github.com/luoguoxiong/hulljs/commit/a332989)) 125 | * v0.0.6 ([45d2cdc](https://github.com/luoguoxiong/hulljs/commit/45d2cdc)) 126 | * v0.0.7 ([e4ab4fd](https://github.com/luoguoxiong/hulljs/commit/e4ab4fd)) 127 | * v0.0.8 ([b8131c9](https://github.com/luoguoxiong/hulljs/commit/b8131c9)) 128 | * v0.0.9 ([3c57a80](https://github.com/luoguoxiong/hulljs/commit/3c57a80)) 129 | * v0.1.0 ([da199ef](https://github.com/luoguoxiong/hulljs/commit/da199ef)) 130 | * v0.1.0 ([1e16cfc](https://github.com/luoguoxiong/hulljs/commit/1e16cfc)) 131 | * v0.1.0 ([9857d8a](https://github.com/luoguoxiong/hulljs/commit/9857d8a)) 132 | * v0.1.0 ([ef972e3](https://github.com/luoguoxiong/hulljs/commit/ef972e3)) 133 | * v0.1.0 ([3ac3e8b](https://github.com/luoguoxiong/hulljs/commit/3ac3e8b)) 134 | * v0.1.0 ([5e6c390](https://github.com/luoguoxiong/hulljs/commit/5e6c390)) 135 | * v0.1.0-alpha.0 ([23089e0](https://github.com/luoguoxiong/hulljs/commit/23089e0)) 136 | * v0.1.1 ([9c657a9](https://github.com/luoguoxiong/hulljs/commit/9c657a9)) 137 | * v0.2.0 ([218cbd6](https://github.com/luoguoxiong/hulljs/commit/218cbd6)) 138 | * v0.2.1 ([a5c27da](https://github.com/luoguoxiong/hulljs/commit/a5c27da)) 139 | * v1.1.0 ([a419a9c](https://github.com/luoguoxiong/hulljs/commit/a419a9c)) 140 | * docs: 完善文档 ([a838c45](https://github.com/luoguoxiong/hulljs/commit/a838c45)) 141 | * docs: 完善文档 ([a4ed041](https://github.com/luoguoxiong/hulljs/commit/a4ed041)) 142 | * docs: 完善文档 ([5ffcdfc](https://github.com/luoguoxiong/hulljs/commit/5ffcdfc)) 143 | * feat: 1.0.0 ([a171bf2](https://github.com/luoguoxiong/hulljs/commit/a171bf2)) 144 | * feat: add packages @hulljs/utils ([6a4818d](https://github.com/luoguoxiong/hulljs/commit/6a4818d)) 145 | * feat: add vue template ([05701ca](https://github.com/luoguoxiong/hulljs/commit/05701ca)) 146 | * feat: ci ([f0c0a38](https://github.com/luoguoxiong/hulljs/commit/f0c0a38)) 147 | * feat: cli ([8110675](https://github.com/luoguoxiong/hulljs/commit/8110675)) 148 | * feat: cli ([0d71547](https://github.com/luoguoxiong/hulljs/commit/0d71547)) 149 | * feat: cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6)) 150 | * feat: hullci ([94c8aa1](https://github.com/luoguoxiong/hulljs/commit/94c8aa1)) 151 | * feat: hullci template ([d83a676](https://github.com/luoguoxiong/hulljs/commit/d83a676)) 152 | * feat: ok ([824478b](https://github.com/luoguoxiong/hulljs/commit/824478b)) 153 | * feat: test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af)) 154 | * feat: test ([ae57978](https://github.com/luoguoxiong/hulljs/commit/ae57978)) 155 | * feat: test ([7e8d16f](https://github.com/luoguoxiong/hulljs/commit/7e8d16f)) 156 | * feat: test ([412a43b](https://github.com/luoguoxiong/hulljs/commit/412a43b)) 157 | * feat: test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701c)) 158 | * feat: test ([9bb75e2](https://github.com/luoguoxiong/hulljs/commit/9bb75e2)) 159 | * feat: test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cd)) 160 | * feat: test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da)) 161 | * feat: test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c)) 162 | * feat: test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43)) 163 | * feat: test ([692ac11](https://github.com/luoguoxiong/hulljs/commit/692ac11)) 164 | * feat: test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f59250)) 165 | * feat: vite doing ([0e359e8](https://github.com/luoguoxiong/hulljs/commit/0e359e8)) 166 | * chore: cli ([983827c](https://github.com/luoguoxiong/hulljs/commit/983827c)) 167 | * chore(build): release ([fa1ac7e](https://github.com/luoguoxiong/hulljs/commit/fa1ac7e)) 168 | 169 | 170 | 171 | 172 | 173 | ## 0.1.1 (2022-07-29) 174 | 175 | * fix: update template version ([ba1e9dc](https://github.com/luoguoxiong/hulljs/commit/ba1e9dc)) 176 | 177 | 178 | 179 | 180 | 181 | ## 0.1.0 (2022-07-28) 182 | 183 | **Note:** Version bump only for package @hulljs/cli 184 | 185 | 186 | 187 | 188 | 189 | ## 0.0.9 (2022-06-16) 190 | 191 | * fix: 添加vite额外插件配置 ([1146789](https://github.com/luoguoxiong/hulljs/commit/1146789)) 192 | * docs: 完善文档 ([a838c45](https://github.com/luoguoxiong/hulljs/commit/a838c45)) 193 | 194 | 195 | 196 | 197 | 198 | ## 0.0.8 (2022-06-12) 199 | 200 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 201 | 202 | 203 | 204 | 205 | 206 | ## 0.0.7 (2022-06-12) 207 | 208 | * fix: 优化cli template ([7e42ac4](https://github.com/luoguoxiong/hulljs/commit/7e42ac4)) 209 | 210 | 211 | 212 | 213 | 214 | ## 0.0.6 (2022-06-11) 215 | 216 | **Note:** Version bump only for package @hulljs/cli 217 | 218 | 219 | 220 | 221 | 222 | ## 0.0.5 (2022-06-11) 223 | 224 | * fix: cli log ([8dfb859](https://github.com/luoguoxiong/hulljs/commit/8dfb859)) 225 | 226 | 227 | 228 | 229 | 230 | ## 0.0.4 (2022-06-11) 231 | 232 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 233 | * fix: test ([cc9ab8b](https://github.com/luoguoxiong/hulljs/commit/cc9ab8b)) 234 | 235 | 236 | 237 | 238 | 239 | ## 0.0.3 (2022-06-11) 240 | 241 | * fix: test ([cc9ab8b](https://github.com/luoguoxiong/hulljs/commit/cc9ab8b)) 242 | 243 | 244 | 245 | 246 | 247 | ## [0.1.0](https://github.com/luoguoxiong/hulljs/compare/v0.0.3...v0.1.0) (2022-06-11) 248 | 249 | 250 | ### 🐛 Bug Fixes | Bug 修复 251 | 252 | * add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b27e89bef094a0d7f3ade77122395a78bc0)) 253 | 254 | 255 | 256 | ## 0.1.0 (2022-06-10) 257 | 258 | 259 | ### ⚠ BREAKING CHANGES 260 | 261 | * send an email 262 | 263 | ### 📝 Documentation | 文档 264 | 265 | * 完善文档 ([a4ed041](https://github.com/luoguoxiong/hulljs/commit/a4ed041ea0aac4fb119559ca5c898c4e5cfba2f3)) 266 | * 完善文档 ([5ffcdfc](https://github.com/luoguoxiong/hulljs/commit/5ffcdfcf0c94885c0ea05481102acc8ea765a08a)) 267 | 268 | 269 | ### 🐛 Bug Fixes | Bug 修复 270 | 271 | * cli release ([7ef199d](https://github.com/luoguoxiong/hulljs/commit/7ef199d339da8103fcc24219a6d589cde09ee3de)) 272 | * test ([a3bb52a](https://github.com/luoguoxiong/hulljs/commit/a3bb52a9a04bc713e3d470eb7b081005a31a48ee)) 273 | * vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec7273b817f76ad359cfb8e9dabbb0eed7f04)) 274 | 275 | 276 | ### ✨ Features | 新功能 277 | 278 | * 1.0.0 ([a171bf2](https://github.com/luoguoxiong/hulljs/commit/a171bf2637f50a4ef6a757200d38affd9d74c742)) 279 | * add packages @hulljs/utils ([6a4818d](https://github.com/luoguoxiong/hulljs/commit/6a4818dfd32770136734027c866787552e496ced)) 280 | * add vue template ([05701ca](https://github.com/luoguoxiong/hulljs/commit/05701cabdc6b9dc370a00be8158a7fa993ee63b3)) 281 | * ci ([f0c0a38](https://github.com/luoguoxiong/hulljs/commit/f0c0a383aea043c64dc0f4cb23fbd722073ab7b2)) 282 | * cli ([0d71547](https://github.com/luoguoxiong/hulljs/commit/0d7154739f2af99f097f5857e5e4da7a0887b8c1)) 283 | * cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6e44439cb94d1080cc3e0ee6556271383c)) 284 | * hullci ([94c8aa1](https://github.com/luoguoxiong/hulljs/commit/94c8aa17cc0cf1d53027c87e9f9dca80bb7a5b3b)) 285 | * hullci template ([d83a676](https://github.com/luoguoxiong/hulljs/commit/d83a67617d322a09d0d48d1c871bb6422f26077c)) 286 | * send an email ([c2493c5](https://github.com/luoguoxiong/hulljs/commit/c2493c5831a8a454f88e6f12494755443cb43e0a)) 287 | * test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af4f4a0fac7ce23bf0e3aa89e4577d9073b)) 288 | * test ([ae57978](https://github.com/luoguoxiong/hulljs/commit/ae57978001f3b7d7760cb0510e6baa7fa3bb8972)) 289 | * test ([7e8d16f](https://github.com/luoguoxiong/hulljs/commit/7e8d16f2debada9c6039c458bdbf289703fd503c)) 290 | * test ([412a43b](https://github.com/luoguoxiong/hulljs/commit/412a43b82ec447ddc05c8be412e84a100661dd38)) 291 | * test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701cb048f668ff4ec2d1ee1cb21e8ef87f930)) 292 | * test ([9bb75e2](https://github.com/luoguoxiong/hulljs/commit/9bb75e230ed96033daa88b43c32d02af73cf5908)) 293 | * test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cdcdbdb51c0a09f54b980e19320e94eb02c)) 294 | * test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da4ad397f984352294fd4c66e994b35a74f)) 295 | * test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c0e6d9e1fbcc37bf3a5d659978c81289b0)) 296 | * test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43edde66d27b8d1eaed0fecd65d9b812587)) 297 | * test ([692ac11](https://github.com/luoguoxiong/hulljs/commit/692ac11d93107e894184e05dd1941eabe7867b78)) 298 | * test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f592508321fab77b739d9977e293b49063fb173)) 299 | * vite doing ([0e359e8](https://github.com/luoguoxiong/hulljs/commit/0e359e830031dcd14792a7ef4e3a85768b1ce11d)) 300 | 301 | 302 | 303 | ### [0.2.1](https://github.com/luoguoxiong/hulljs/compare/v0.2.0...v0.2.1) (2022-06-10) 304 | 305 | 306 | ### 🐛 Bug Fixes | Bug 修复 307 | 308 | * test ([a3bb52a](https://github.com/luoguoxiong/hulljs/commit/a3bb52a9a04bc713e3d470eb7b081005a31a48ee)) 309 | -------------------------------------------------------------------------------- /packages/hull-cli/bin/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | const semver = require('semver'); 3 | const { chalk } = require('@hulljs/utils'); 4 | checkNodeVersion(); 5 | 6 | function checkNodeVersion() { 7 | 8 | const packageJson = require('../package.json'); 9 | 10 | if (!packageJson.engines || !packageJson.engines.node) { 11 | return; 12 | } 13 | 14 | if (!semver.satisfies(process.version, packageJson.engines.node)) { 15 | console.error( 16 | chalk.red( 17 | 'You are running Node %s.\n' + 18 | 'hulljs requires Node %s or higher.\n' + 19 | 'Please update your version of Node.', 20 | ), 21 | process.version, 22 | packageJson.engines.node, 23 | ); 24 | process.exit(1); 25 | } 26 | } 27 | 28 | require('../dist'); 29 | -------------------------------------------------------------------------------- /packages/hull-cli/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hulljs/cli", 3 | "version": "0.8.2", 4 | "description": "hull-cli", 5 | "main": "index.js", 6 | "bin": { 7 | "hull": "./bin/index.js" 8 | }, 9 | "scripts": { 10 | "build": "tsc", 11 | "watch": "tsc -w" 12 | }, 13 | "keywords": [ 14 | "hull-cli" 15 | ], 16 | "author": "luoguoxiong", 17 | "license": "ISC", 18 | "devDependencies": { 19 | "@types/fs-extra": "^9.0.13", 20 | "@types/prompts": "^2.0.14", 21 | "@types/validate-npm-package-name": "^3.0.3", 22 | "typescript": "^4.6.4" 23 | }, 24 | "dependencies": { 25 | "@hulljs/build": "0.8.2", 26 | "@hulljs/utils": "0.8.0", 27 | "cac": "^6.7.12", 28 | "fs-extra": "^10.0.1", 29 | "prompts": "^2.4.2", 30 | "semver": "^7.3.7", 31 | "validate-npm-package-name": "^4.0.0" 32 | }, 33 | "engines": { 34 | "node": ">= 14.0.0" 35 | }, 36 | "publishConfig": { 37 | "access": "public" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /packages/hull-cli/src/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'hyperquest' 2 | declare module 'tmp' 3 | declare module 'tar-pack' 4 | declare module 'fs-extra' 5 | declare module 'validate-npm-package-name' 6 | declare module 'semver' 7 | -------------------------------------------------------------------------------- /packages/hull-cli/src/index.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | import os from 'os'; 3 | import cac from 'cac'; 4 | import fs from 'fs-extra'; 5 | import { chalk } from '@hulljs/utils'; 6 | import { build, IBuildOptions, CliIn } from '@hulljs/build'; 7 | import validateProjectName from 'validate-npm-package-name'; 8 | import prompts from 'prompts'; 9 | 10 | 11 | const { version } = require('../package.json'); 12 | 13 | const cli = cac(); 14 | 15 | cli.version(version); 16 | 17 | const checkAppDir = (appRoot: string, projectName: string) => { 18 | const isEsitDir = fs.existsSync(path.resolve(appRoot, projectName)); 19 | if(isEsitDir) { 20 | console.log(chalk.red(`${appRoot} is exisit ${projectName} Dir!`)); 21 | process.exit(1); 22 | } 23 | }; 24 | 25 | const verifyAppName = (appName: string) => { 26 | const validationResult = validateProjectName(appName); 27 | if (!validationResult.validForNewPackages) { 28 | console.error( 29 | chalk.red( 30 | `Cannot create a project named ${chalk.green( 31 | `"${appName}"`, 32 | )} because of npm naming restrictions:\n`, 33 | ), 34 | ); 35 | [ 36 | ...(validationResult.errors || []), 37 | ...(validationResult.warnings || []), 38 | ].forEach((error) => { 39 | console.error(chalk.red(` * ${error}`)); 40 | }); 41 | console.error(chalk.red('\nPlease choose a different project name.')); 42 | process.exit(1); 43 | } 44 | }; 45 | 46 | const copyTemplateToApp = (templateName: string, appRoot: string, projectName: string) => { 47 | fs.copySync(path.join(__dirname, `../template/${templateName}`), path.resolve(appRoot, projectName)); 48 | }; 49 | 50 | cli 51 | .command('init ', 'create app project!') 52 | .action(async(projectName: string) => { 53 | const appRoot = process.cwd(); 54 | // 校验prjectName是否合法 55 | verifyAppName(projectName); 56 | // 检查是否存在该工程 57 | checkAppDir(appRoot, projectName); 58 | const isReact = await prompts([ 59 | { 60 | type: 'select', 61 | name: 'isReact', 62 | message: 'is use react or vue?', 63 | choices: [ 64 | { title: 'react', value: true }, 65 | { title: 'vue', value: false }, 66 | ], 67 | }, 68 | ]); 69 | 70 | if(isReact.isReact === undefined){ 71 | return; 72 | } 73 | const isTs = await prompts([ 74 | { 75 | type: 'select', 76 | name: 'isTs', 77 | message: 'is use TypeScript?', 78 | choices: [ 79 | { title: 'true', value: true }, 80 | { title: 'false', value: false }, 81 | ], 82 | }, 83 | ]); 84 | 85 | if(isTs.isTs === undefined){ 86 | return; 87 | } 88 | 89 | // 创建工程 90 | fs.ensureDirSync(path.resolve(appRoot, projectName)); 91 | 92 | const options = { ...isReact, isWebpack: true, ...isTs }; 93 | 94 | const templateName = [ 95 | `${options.isReact ? 'react' : 'vue'}`, 96 | `${options.isTs ? 'ts' : 'js'}`, 97 | ]; 98 | // 复制模板 99 | copyTemplateToApp(templateName.join('-'), appRoot, projectName); 100 | 101 | 102 | 103 | const config = JSON.parse(fs.readFileSync(path.join(appRoot, `${projectName}/package.json`)).toString()) || {}; 104 | 105 | 106 | const packageJson = { 107 | name: projectName, 108 | version: '0.1.0', 109 | ...config, 110 | devDependencies: { 111 | ...config.devDependencies, 112 | '@hulljs/cli': version, 113 | }, 114 | }; 115 | fs.writeFileSync( 116 | path.join(appRoot, `${projectName}/package.json`), 117 | JSON.stringify(packageJson, null, 2) + os.EOL, 118 | ); 119 | console.log(chalk.green('create success!')); 120 | console.log(chalk.gray(`Created ${projectName} at ./${projectName}`)); 121 | console.log(chalk.gray('Inside that directory, you can use commands:')); 122 | console.log(); 123 | console.log(chalk.blue(' npm install')); 124 | console.log(chalk.gray(' Get the app dependencies.')); 125 | console.log(); 126 | console.log(chalk.blue(' npm run dev')); 127 | console.log(chalk.gray(' Starts the development server.')); 128 | console.log(); 129 | console.log(chalk.blue(' npm run build')); 130 | console.log( 131 | chalk.gray( 132 | ' Build the app into static files for production.', 133 | ), 134 | ); 135 | console.log(); 136 | console.log(chalk.blue(' npm run server')); 137 | console.log( 138 | chalk.gray( 139 | ' Build the app into static files for production and Run static Server.', 140 | ), 141 | ); 142 | }); 143 | 144 | cli 145 | .command('dev', 'Start dev server!') 146 | .option('--port ', 'dev server port') 147 | .option('--vite', 'is use vite?') 148 | .action((options: CliIn) => { 149 | try { 150 | const option: IBuildOptions = { 151 | appDirectory: fs.realpathSync(process.cwd()), 152 | port: options.port, 153 | env: 'development', 154 | buildTool: options.vite ? 'vite' : 'webpack', 155 | analyzer: false, 156 | }; 157 | build(option, 'dev'); 158 | } catch (error: any) { 159 | throw Error(error); 160 | } 161 | }); 162 | 163 | cli 164 | .command('build', 'Build web app resource!') 165 | .option('--vite', 'is use vite?') 166 | .option('--analyzer', 'is use BundleAnalyzer?') 167 | .action((options: CliIn) => { 168 | try { 169 | const option: IBuildOptions = { 170 | appDirectory: fs.realpathSync(process.cwd()), 171 | env: 'production', 172 | buildTool: options.vite ? 'vite' : 'webpack', 173 | analyzer: options.analyzer, 174 | }; 175 | build(option, 'build'); 176 | } catch (error: any) { 177 | throw Error(error); 178 | } 179 | }); 180 | 181 | cli 182 | .command('server', 'Start static server for production app!') 183 | .option('--vite', 'is use vite?') 184 | .option('--port ', 'static server port') 185 | .action((options: CliIn) => { 186 | try { 187 | const option: IBuildOptions = { 188 | appDirectory: fs.realpathSync(process.cwd()), 189 | env: 'production', 190 | buildTool: options.vite ? 'vite' : 'webpack', 191 | port: options.port, 192 | }; 193 | build(option, 'server'); 194 | } catch (error: any) { 195 | throw Error(error); 196 | } 197 | }); 198 | 199 | 200 | cli.help(); 201 | 202 | cli.parse(); 203 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/.browserslistrc: -------------------------------------------------------------------------------- 1 | [production] 2 | >0.2% 3 | not dead 4 | not op_mini all 5 | 6 | [development] 7 | last 1 chrome version 8 | last 1 firefox version 9 | last 1 safari version -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@hulljs/eslint-config-hull-app/react'], 3 | }; 4 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/hull.conf.js: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | 3 | export default { 4 | projectType: 'react', 5 | entry: path.resolve(__dirname, './src/index'), 6 | }; 7 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "baseUrl": ".", 5 | "jsx": "react", 6 | "paths": { 7 | "@/src/*": ["./src/*"] 8 | } 9 | }, 10 | "files": ["./index.d.ts"], 11 | "include": ["src/**/*"], 12 | "exclude": ["node_modules"] 13 | } 14 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "hull dev", 4 | "dev:vite": "hull dev --vite", 5 | "build": "hull build", 6 | "build:vite": "hull build --vite", 7 | "server": "hull server", 8 | "server:vite": "hull server --vite" 9 | }, 10 | "devDependencies": { 11 | "@hulljs/eslint-config-hull-app": "^0.1.0" 12 | }, 13 | "dependencies": { 14 | "react": "^17.0.1", 15 | "react-dom": "^17.0.1" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/src/app.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/src/app.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from '@/src/static/logo.svg'; 3 | import styles from '@/src/app.module.less'; 4 | import './app.css'; 5 | 6 | function App() { 7 | return ( 8 |
9 |
10 | logo 14 |

15 | Edit src/app.js and save to reload. 16 |

17 | 23 | Learn React 24 | 25 |
26 |
27 | ); 28 | } 29 | 30 | export default App; 31 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/src/app.module.less: -------------------------------------------------------------------------------- 1 | 2 | .App { 3 | text-align: center; 4 | } 5 | 6 | .App-logo { 7 | height: 40vmin; 8 | pointer-events: none; 9 | border-radius: 50%; 10 | } 11 | 12 | @media (prefers-reduced-motion: no-preference) { 13 | .App-logo { 14 | animation: App-logo-spin infinite 20s linear; 15 | } 16 | } 17 | 18 | .App-header { 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | min-height: 100vh; 24 | color: white; 25 | font-size: calc(10px + 2vmin); 26 | background-color: #282c34; 27 | } 28 | 29 | .App-link { 30 | color: #61dafb; 31 | } 32 | 33 | @keyframes App-logo-spin { 34 | from { 35 | transform: rotate(0deg); 36 | } 37 | to { 38 | transform: rotate(360deg); 39 | } 40 | } -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/src/index.jsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from '@/src/app'; 4 | 5 | ReactDOM.render( 6 | , 7 | document.getElementById('root'), 8 | ); 9 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-js/src/static/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/.browserslistrc: -------------------------------------------------------------------------------- 1 | [production] 2 | >0.2% 3 | not dead 4 | not op_mini all 5 | 6 | [development] 7 | last 1 chrome version 8 | last 1 firefox version 9 | last 1 safari version -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@hulljs/eslint-config-hull-app/react'], 3 | }; 4 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/hull.conf.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | 3 | export default { 4 | projectType: 'react', 5 | entry: path.resolve(__dirname, './src/index'), 6 | }; 7 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/index.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.svg' 2 | declare module '*.css' 3 | declare module '*.less' 4 | declare module '*.scss' 5 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "hull dev", 4 | "dev:vite": "hull dev --vite", 5 | "build": "hull build", 6 | "build:vite": "hull build --vite", 7 | "server": "hull server", 8 | "server:vite": "hull server --vite" 9 | }, 10 | "devDependencies": { 11 | "@types/react": "^18.0.9", 12 | "@types/react-dom": "^18.0.4", 13 | "@hulljs/eslint-config-hull-app": "^0.1.0" 14 | }, 15 | "dependencies": { 16 | "react": "^17.0.1", 17 | "react-dom": "^17.0.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/src/app.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/src/app.module.less: -------------------------------------------------------------------------------- 1 | 2 | .App { 3 | text-align: center; 4 | } 5 | 6 | .App-logo { 7 | height: 40vmin; 8 | pointer-events: none; 9 | border-radius: 50%; 10 | } 11 | 12 | @media (prefers-reduced-motion: no-preference) { 13 | .App-logo { 14 | animation: App-logo-spin infinite 20s linear; 15 | } 16 | } 17 | 18 | .App-header { 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | min-height: 100vh; 24 | color: white; 25 | font-size: calc(10px + 2vmin); 26 | background-color: #282c34; 27 | } 28 | 29 | .App-link { 30 | color: #61dafb; 31 | } 32 | 33 | @keyframes App-logo-spin { 34 | from { 35 | transform: rotate(0deg); 36 | } 37 | to { 38 | transform: rotate(360deg); 39 | } 40 | } -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/src/app.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import logo from '@/src/static/logo.svg'; 3 | import styles from '@/src/app.module.less'; 4 | import './app.css'; 5 | 6 | function App() { 7 | return ( 8 |
9 |
10 | logo 14 |

15 | Edit src/app.js and save to reload. 16 |

17 | 23 | Learn React 24 | 25 |
26 |
27 | ); 28 | } 29 | 30 | export default App; 31 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/src/index.tsx: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import App from '@/src/app'; 4 | 5 | ReactDOM.render( 6 | , 7 | document.getElementById('root'), 8 | ); 9 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/src/static/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /packages/hull-cli/template/react-ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "esModuleInterop": true, 4 | "baseUrl": ".", 5 | "jsx": "react", 6 | "paths": { 7 | "@/src/*": ["./src/*"] 8 | } 9 | }, 10 | "files": ["./index.d.ts"], 11 | "include": ["src/**/*"], 12 | "exclude": ["node_modules"] 13 | } 14 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/.browserslistrc: -------------------------------------------------------------------------------- 1 | [production] 2 | >0.2% 3 | not dead 4 | not op_mini all 5 | 6 | [development] 7 | last 1 chrome version 8 | last 1 firefox version 9 | last 1 safari version -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@hulljs/eslint-config-hull-app/vue'], 3 | }; 4 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/hull.conf.js: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | 3 | export default { 4 | projectType: 'vue3', 5 | entry: path.resolve(__dirname, './src/index'), 6 | }; 7 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/jsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "@/src/*": ["./src/*"] 6 | }, 7 | "strictNullChecks": false, 8 | "moduleResolution": "node", 9 | "esModuleInterop": true, 10 | "experimentalDecorators": true, 11 | "jsx": "preserve", 12 | "noUnusedParameters": true, 13 | "noUnusedLocals": true, 14 | "noImplicitAny": false, 15 | "target": "es6", 16 | "skipLibCheck": true, 17 | "allowJs": true, 18 | "importsNotUsedAsValues": "preserve" 19 | }, 20 | "include": ["src/**/*"] 21 | } 22 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "hull dev", 4 | "dev:vite": "hull dev --vite", 5 | "build": "hull build", 6 | "build:vite": "hull build --vite", 7 | "server": "hull server", 8 | "server:vite": "hull server --vite" 9 | }, 10 | "devDependencies": { 11 | "@hulljs/eslint-config-hull-app": "^0.1.0" 12 | }, 13 | "dependencies": { 14 | "vue": "^3.2.36" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/src/App.vue: -------------------------------------------------------------------------------- 1 | 23 | 60 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/src/app.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/src/index.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue'; 2 | import App from '@/src/App.vue'; 3 | import '@/src/app.css'; 4 | const app = createApp(App); 5 | app.mount('#root'); 6 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import type { DefineComponent } from 'vue'; 3 | 4 | const component: DefineComponent; 5 | export default component; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-js/src/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoguoxiong/hulljs/191b09d78725afa0d40cc2d8cefacba92eff8d6c/packages/hull-cli/template/vue-js/src/static/logo.png -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/.browserslistrc: -------------------------------------------------------------------------------- 1 | [production] 2 | >0.2% 3 | not dead 4 | not op_mini all 5 | 6 | [development] 7 | last 1 chrome version 8 | last 1 firefox version 9 | last 1 safari version -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | extends: ['@hulljs/eslint-config-hull-app/vue'], 3 | }; 4 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | node_modules -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/hull.conf.ts: -------------------------------------------------------------------------------- 1 | import path from 'path'; 2 | 3 | export default { 4 | projectType: 'vue3', 5 | entry: path.resolve(__dirname, './src/index'), 6 | }; 7 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "dev": "hull dev", 4 | "dev:vite": "hull dev --vite", 5 | "build": "hull build", 6 | "build:vite": "hull build --vite", 7 | "server": "hull server", 8 | "server:vite": "hull server --vite" 9 | }, 10 | "devDependencies": { 11 | "@hulljs/eslint-config-hull-app": "^0.1.0" 12 | }, 13 | "dependencies": { 14 | "vue": "^3.2.36" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/src/App.vue: -------------------------------------------------------------------------------- 1 | 23 | 60 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/src/app.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/src/index.ts: -------------------------------------------------------------------------------- 1 | import { createApp } from 'vue'; 2 | import App from '@/src/App.vue'; 3 | import '@/src/app.css'; 4 | const app = createApp(App); 5 | app.mount('#root'); 6 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/src/shims-vue.d.ts: -------------------------------------------------------------------------------- 1 | declare module '*.vue' { 2 | import type { DefineComponent } from 'vue'; 3 | 4 | const component: DefineComponent; 5 | export default component; 6 | } 7 | 8 | -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/src/static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoguoxiong/hulljs/191b09d78725afa0d40cc2d8cefacba92eff8d6c/packages/hull-cli/template/vue-ts/src/static/logo.png -------------------------------------------------------------------------------- /packages/hull-cli/template/vue-ts/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "baseUrl": ".", 4 | "paths": { 5 | "@/src/*": ["./src/*"] 6 | }, 7 | "strictNullChecks": false, 8 | "moduleResolution": "node", 9 | "esModuleInterop": true, 10 | "experimentalDecorators": true, 11 | "jsx": "preserve", 12 | "noUnusedParameters": true, 13 | "noUnusedLocals": true, 14 | "noImplicitAny": false, 15 | "target": "es6", 16 | "skipLibCheck": true, 17 | "allowJs": true, 18 | "importsNotUsedAsValues": "preserve" 19 | }, 20 | "include": ["src/**/*"] 21 | } 22 | -------------------------------------------------------------------------------- /packages/hull-cli/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "sourceMap": true, 8 | "resolveJsonModule": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "skipDefaultLibCheck": true, 12 | "declaration": true, 13 | "outDir": "./dist", 14 | "rootDir": "./src", 15 | "baseUrl": ".", 16 | }, 17 | "include": ["./src"], 18 | "exclude": ["./template"] 19 | } -------------------------------------------------------------------------------- /packages/hull-utils/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | CHANGELOG.md 3 | tsconfig.json -------------------------------------------------------------------------------- /packages/hull-utils/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 0.8.0 (2022-11-17) 7 | 8 | **Note:** Version bump only for package @hulljs/utils 9 | 10 | 11 | 12 | 13 | 14 | ## 0.7.0 (2022-11-17) 15 | 16 | **Note:** Version bump only for package @hulljs/utils 17 | 18 | 19 | 20 | 21 | 22 | ## 0.6.0 (2022-11-17) 23 | 24 | **Note:** Version bump only for package @hulljs/utils 25 | 26 | 27 | 28 | 29 | 30 | ## 0.5.0 (2022-11-16) 31 | 32 | **Note:** Version bump only for package @hulljs/utils 33 | 34 | 35 | 36 | 37 | 38 | ## 0.4.0 (2022-11-14) 39 | 40 | **Note:** Version bump only for package @hulljs/utils 41 | 42 | 43 | 44 | 45 | 46 | ## 0.3.0 (2022-11-07) 47 | 48 | **Note:** Version bump only for package @hulljs/utils 49 | 50 | 51 | 52 | 53 | 54 | ## 0.2.0 (2022-08-31) 55 | 56 | * v0.0.1 ([abb7235](https://github.com/luoguoxiong/hulljs/commit/abb7235)) 57 | * v0.0.1 ([9741168](https://github.com/luoguoxiong/hulljs/commit/9741168)) 58 | * v0.0.1 ([fd6dff8](https://github.com/luoguoxiong/hulljs/commit/fd6dff8)) 59 | * v0.0.1 ([7bdb68f](https://github.com/luoguoxiong/hulljs/commit/7bdb68f)) 60 | * v0.0.1 ([0d7b9a0](https://github.com/luoguoxiong/hulljs/commit/0d7b9a0)) 61 | * v0.0.1 ([23a8219](https://github.com/luoguoxiong/hulljs/commit/23a8219)) 62 | * v0.0.1 ([2e7d627](https://github.com/luoguoxiong/hulljs/commit/2e7d627)) 63 | * v0.0.1-alpha.0 ([2bee034](https://github.com/luoguoxiong/hulljs/commit/2bee034)) 64 | * v0.0.1-alpha.0 ([91ec57e](https://github.com/luoguoxiong/hulljs/commit/91ec57e)) 65 | * v0.0.2 ([484bbd2](https://github.com/luoguoxiong/hulljs/commit/484bbd2)) 66 | * v0.0.2 ([93bde13](https://github.com/luoguoxiong/hulljs/commit/93bde13)) 67 | * v0.0.2 ([5869178](https://github.com/luoguoxiong/hulljs/commit/5869178)) 68 | * v0.0.2 ([c02f578](https://github.com/luoguoxiong/hulljs/commit/c02f578)) 69 | * v0.0.2-alpha.0 ([92972ca](https://github.com/luoguoxiong/hulljs/commit/92972ca)) 70 | * v0.0.4 ([64c2b6a](https://github.com/luoguoxiong/hulljs/commit/64c2b6a)) 71 | * v0.0.5 ([a332989](https://github.com/luoguoxiong/hulljs/commit/a332989)) 72 | * v0.0.6 ([45d2cdc](https://github.com/luoguoxiong/hulljs/commit/45d2cdc)) 73 | * v0.0.7 ([e4ab4fd](https://github.com/luoguoxiong/hulljs/commit/e4ab4fd)) 74 | * v0.0.8 ([b8131c9](https://github.com/luoguoxiong/hulljs/commit/b8131c9)) 75 | * v0.0.9 ([3c57a80](https://github.com/luoguoxiong/hulljs/commit/3c57a80)) 76 | * v0.1.0 ([da199ef](https://github.com/luoguoxiong/hulljs/commit/da199ef)) 77 | * v0.1.0 ([1e16cfc](https://github.com/luoguoxiong/hulljs/commit/1e16cfc)) 78 | * v0.1.0 ([9857d8a](https://github.com/luoguoxiong/hulljs/commit/9857d8a)) 79 | * v0.1.0 ([ef972e3](https://github.com/luoguoxiong/hulljs/commit/ef972e3)) 80 | * v0.1.0 ([3ac3e8b](https://github.com/luoguoxiong/hulljs/commit/3ac3e8b)) 81 | * v0.1.0 ([5e6c390](https://github.com/luoguoxiong/hulljs/commit/5e6c390)) 82 | * v0.1.0-alpha.0 ([23089e0](https://github.com/luoguoxiong/hulljs/commit/23089e0)) 83 | * v0.2.0 ([218cbd6](https://github.com/luoguoxiong/hulljs/commit/218cbd6)) 84 | * fix: add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b2)) 85 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 86 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 87 | * fix: vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec72)) 88 | * feat: 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407)) 89 | * feat: add packages @hulljs/utils ([6a4818d](https://github.com/luoguoxiong/hulljs/commit/6a4818d)) 90 | * feat: build ([e0c8bc4](https://github.com/luoguoxiong/hulljs/commit/e0c8bc4)) 91 | * feat: cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6)) 92 | * feat: ok ([824478b](https://github.com/luoguoxiong/hulljs/commit/824478b)) 93 | * feat: preset-hull-app ([c54033f](https://github.com/luoguoxiong/hulljs/commit/c54033f)) 94 | * feat: test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af)) 95 | * feat: test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701c)) 96 | * feat: test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cd)) 97 | * feat: test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da)) 98 | * feat: test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c)) 99 | * feat: test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43)) 100 | * feat: test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f59250)) 101 | * chore(build): release ([fa1ac7e](https://github.com/luoguoxiong/hulljs/commit/fa1ac7e)) 102 | * docs: 完善文档 ([02f0020](https://github.com/luoguoxiong/hulljs/commit/02f0020)) 103 | 104 | 105 | 106 | 107 | 108 | ## 0.1.0 (2022-07-28) 109 | 110 | **Note:** Version bump only for package @hulljs/utils 111 | 112 | 113 | 114 | 115 | 116 | ## 0.0.9 (2022-06-16) 117 | 118 | **Note:** Version bump only for package @hulljs/utils 119 | 120 | 121 | 122 | 123 | 124 | ## 0.0.8 (2022-06-12) 125 | 126 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 127 | 128 | 129 | 130 | 131 | 132 | ## 0.0.7 (2022-06-12) 133 | 134 | **Note:** Version bump only for package @hulljs/utils 135 | 136 | 137 | 138 | 139 | 140 | ## 0.0.6 (2022-06-11) 141 | 142 | **Note:** Version bump only for package @hulljs/utils 143 | 144 | 145 | 146 | 147 | 148 | ## 0.0.5 (2022-06-11) 149 | 150 | **Note:** Version bump only for package @hulljs/utils 151 | 152 | 153 | 154 | 155 | 156 | ## 0.0.4 (2022-06-11) 157 | 158 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 159 | 160 | 161 | 162 | 163 | 164 | ## 0.0.3 (2022-06-11) 165 | 166 | **Note:** Version bump only for package @hulljs/utils 167 | 168 | 169 | 170 | 171 | 172 | ## [0.1.0](https://github.com/luoguoxiong/hulljs/compare/v0.0.3...v0.1.0) (2022-06-11) 173 | 174 | 175 | ### 🐛 Bug Fixes | Bug 修复 176 | 177 | * add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b27e89bef094a0d7f3ade77122395a78bc0)) 178 | 179 | 180 | 181 | ## 0.1.0 (2022-06-10) 182 | 183 | 184 | ### 📝 Documentation | 文档 185 | 186 | * 完善文档 ([02f0020](https://github.com/luoguoxiong/hulljs/commit/02f0020582221f1e6443d5f079a717c7a7c6c63f)) 187 | 188 | 189 | ### 🐛 Bug Fixes | Bug 修复 190 | 191 | * vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec7273b817f76ad359cfb8e9dabbb0eed7f04)) 192 | 193 | 194 | ### ✨ Features | 新功能 195 | 196 | * 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407fcaea1153ff421c41ead174539be99b9b)) 197 | * add packages @hulljs/utils ([6a4818d](https://github.com/luoguoxiong/hulljs/commit/6a4818dfd32770136734027c866787552e496ced)) 198 | * build ([e0c8bc4](https://github.com/luoguoxiong/hulljs/commit/e0c8bc40d475ca5173fe3e86a016b89d0c59b628)) 199 | * cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6e44439cb94d1080cc3e0ee6556271383c)) 200 | * preset-hull-app ([c54033f](https://github.com/luoguoxiong/hulljs/commit/c54033f34bad2175a470e9c0659d76b61ffd54a0)) 201 | * test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af4f4a0fac7ce23bf0e3aa89e4577d9073b)) 202 | * test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701cb048f668ff4ec2d1ee1cb21e8ef87f930)) 203 | * test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cdcdbdb51c0a09f54b980e19320e94eb02c)) 204 | * test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da4ad397f984352294fd4c66e994b35a74f)) 205 | * test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c0e6d9e1fbcc37bf3a5d659978c81289b0)) 206 | * test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43edde66d27b8d1eaed0fecd65d9b812587)) 207 | * test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f592508321fab77b739d9977e293b49063fb173)) 208 | 209 | 210 | 211 | ## [0.2.0](https://github.com/luoguoxiong/hulljs/compare/v0.1.0...v0.2.0) (2022-06-10) 212 | 213 | **Note:** Version bump only for package @hulljs/utils 214 | 215 | 216 | 217 | 218 | 219 | 220 | # [0.1.0](https://github.com/projects/luoguoxiong/repos/hulljs/compare/diff?targetBranch=refs%2Ftags%2Fv0.0.1&sourceBranch=refs%2Ftags%2Fv0.1.0) (2022-06-10) 221 | 222 | **Note:** Version bump only for package @hulljs/utils 223 | -------------------------------------------------------------------------------- /packages/hull-utils/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hulljs/utils", 3 | "version": "0.8.0", 4 | "description": "bull-utils", 5 | "type": "commonjs", 6 | "bin": { 7 | "hull-webpack": "./dist/index.js" 8 | }, 9 | "main": "./dist/index.js", 10 | "types": "./dist/index.d.js", 11 | "scripts": { 12 | "build": "tsc", 13 | "watch": "tsc -w" 14 | }, 15 | "devDependencies": { 16 | "typescript": "^4.6.4" 17 | }, 18 | "engines": { 19 | "node": ">= 14.0.0" 20 | }, 21 | "license": "ISC", 22 | "dependencies": { 23 | "@babel/core": "7.12.3", 24 | "@babel/register": "7.12.1", 25 | "@hulljs/babel-preset-hull-app": "0.8.0", 26 | "chalk": "^4.0.1", 27 | "detect-port-alt": "^1.1.6", 28 | "koa": "^2.13.4", 29 | "koa-static": "^5.0.0", 30 | "koa2-connect-history-api-fallback": "^0.1.3" 31 | }, 32 | "publishConfig": { 33 | "access": "public" 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /packages/hull-utils/src/config.ts: -------------------------------------------------------------------------------- 1 | 2 | export const createConfig = () => { 3 | let config: T; 4 | return { 5 | getConfig: (): T => { 6 | if(config) return config; 7 | throw Error('please setConfig first!'); 8 | }, 9 | setConfig: (_config: T) => { 10 | config = _config; 11 | }, 12 | }; 13 | }; 14 | -------------------------------------------------------------------------------- /packages/hull-utils/src/getExistFile.ts: -------------------------------------------------------------------------------- 1 | import { existsSync } from 'fs'; 2 | import { join } from 'path'; 3 | 4 | interface IGetExistFile{ 5 | appDirectory: string; 6 | files?: string[]; 7 | returnRelative?: boolean; 8 | } 9 | 10 | interface IGetExistFileRe{ 11 | isOk: boolean; 12 | absFilePath: string; 13 | } 14 | 15 | export function getExistFile({ appDirectory, files = [] }: IGetExistFile): IGetExistFileRe { 16 | for (const file of files) { 17 | const absFilePath = join(appDirectory, file); 18 | if (existsSync(absFilePath)) { 19 | return { 20 | isOk: true, 21 | absFilePath, 22 | }; 23 | } 24 | } 25 | return { 26 | isOk: false, 27 | absFilePath: '', 28 | }; 29 | } 30 | -------------------------------------------------------------------------------- /packages/hull-utils/src/getFileExport.ts: -------------------------------------------------------------------------------- 1 | import { isDefault, getExistFile, registerNodeCiBabel } from '.'; 2 | 3 | export const getFileExport = async(appDirectory: string, files: string[]): Promise => { 4 | try { 5 | registerNodeCiBabel(appDirectory, files); 6 | const { isOk, absFilePath } = getExistFile({ appDirectory, files: files, returnRelative: false }); 7 | if(isOk){ 8 | return isDefault(await import(absFilePath)); 9 | }else{ 10 | throw Error(`${appDirectory} isn't has any ${files.join('、')}`); 11 | } 12 | } catch (error: any) { 13 | throw Error(error); 14 | } 15 | }; 16 | -------------------------------------------------------------------------------- /packages/hull-utils/src/getModulesFromConfig.ts: -------------------------------------------------------------------------------- 1 | import { resolve } from 'path'; 2 | import { existsSync, readFileSync } from 'fs'; 3 | import { log } from '.'; 4 | 5 | interface IgetAliasFromConfigRe { 6 | isTypeScript: boolean; 7 | alias: Record; 8 | modules: string[]; 9 | } 10 | 11 | // 从tsconfig.json 和jsconfig.json获取配置 12 | export const getModulesFromConfig = (appDirectory: string): IgetAliasFromConfigRe => { 13 | const tsConfigPath = resolve(appDirectory, 'tsconfig.json'); 14 | const jsConfigPath = resolve(appDirectory, 'jsconfig.json'); 15 | 16 | const hasTsConfig = existsSync(tsConfigPath); 17 | const hasJsConfig = existsSync(jsConfigPath); 18 | 19 | if(hasTsConfig && hasJsConfig){ 20 | log.warn('同时存在 tsconfig.json 和 jsconfig.json,优先使用tsconfig.json'); 21 | } 22 | 23 | 24 | const getAliasFromConfig = (configPath: string): IgetAliasFromConfigRe => { 25 | try { 26 | 27 | const config = JSON.parse(readFileSync(configPath).toString()).compilerOptions || {}; 28 | 29 | 30 | const { baseUrl = '', paths = {} } = config; 31 | const absoluteBaseUrl = resolve(appDirectory, baseUrl); 32 | // why node_modules?? node_modules 不设置 webpackdevserver会出错!!! 33 | const modules = [resolve(appDirectory, 'node_modules'), absoluteBaseUrl, 'node_modules']; 34 | const alias: Record = {}; 35 | 36 | Object.keys(paths).forEach((item) => { 37 | const key = item.replace('/*', ''); 38 | const value = resolve(absoluteBaseUrl, paths[item][0].replace('/*', '').replace('*', '')); 39 | alias[key] = value; 40 | }); 41 | return { 42 | isTypeScript: hasTsConfig, 43 | alias, 44 | modules, 45 | }; 46 | } catch (error: any) { 47 | log.error(error); 48 | throw new Error(error); 49 | } 50 | }; 51 | 52 | const config: IgetAliasFromConfigRe = { 53 | isTypeScript: false, 54 | modules: ['node_modules', resolve(appDirectory, 'node_modules')], 55 | alias: {}, 56 | }; 57 | 58 | return (hasTsConfig || hasJsConfig) ? getAliasFromConfig(hasTsConfig ? tsConfigPath : jsConfigPath) : config; 59 | }; 60 | -------------------------------------------------------------------------------- /packages/hull-utils/src/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module 'detect-port-alt' 2 | declare module 'koa-static' 3 | declare module 'koa' 4 | -------------------------------------------------------------------------------- /packages/hull-utils/src/index.ts: -------------------------------------------------------------------------------- 1 | 2 | import chalk1 from 'chalk'; 3 | export { log } from './log'; 4 | export { getExistFile } from './getExistFile'; 5 | export { getFileExport } from './getFileExport'; 6 | export { registerNodeCiBabel } from './registerNodeCiBabel'; 7 | export { createConfig } from './config'; 8 | export { startStaticServer } from './startStaticServer'; 9 | export { getModulesFromConfig } from './getModulesFromConfig'; 10 | export { checkPort, choosePort } from './usePort'; 11 | export const isDefault = (obj: any): T => obj.default || obj; 12 | export const chalk = chalk1; 13 | -------------------------------------------------------------------------------- /packages/hull-utils/src/log.ts: -------------------------------------------------------------------------------- 1 | import chalk, { ChalkFunction }from 'chalk'; 2 | 3 | const curryLog = ( chalkInstans: ChalkFunction, logType?: string) => (msg: any) => 4 | (logType ? console.log(chalkInstans(`${logType}: ${msg}`)) : console.log(chalkInstans(msg))); 5 | 6 | const colors = [ 7 | 'blue', 8 | 'magenta', 9 | 'gray', 10 | 'redBright', 11 | 'greenBright', 12 | 'yellowBright', 13 | 'blueBright', 14 | 'magentaBright', 15 | 'cyanBright', 16 | ]; 17 | 18 | let index = 0; 19 | 20 | const getChalkInstance = () => { 21 | index = index % (colors.length - 1); 22 | const color = colors[index] as keyof ChalkFunction; 23 | index++; 24 | return chalk[color] as ChalkFunction; 25 | }; 26 | 27 | 28 | export const log = { 29 | error: curryLog( chalk.red, 'error'), 30 | warn: curryLog( chalk.yellow, 'warn'), 31 | success: curryLog(chalk.green, 'success'), 32 | msg: curryLog(chalk.cyan), 33 | free: (msg: string): void => curryLog(getChalkInstance())(msg), 34 | }; 35 | 36 | 37 | -------------------------------------------------------------------------------- /packages/hull-utils/src/registerNodeCiBabel.ts: -------------------------------------------------------------------------------- 1 | import { join } from 'path'; 2 | import babel, { IGetBabelOptions } from '@hulljs/babel-preset-hull-app'; 3 | 4 | const slash = (input: string) => { 5 | const isExtendedLengthPath = /^\\\\\?\\/.test(input); 6 | 7 | if (isExtendedLengthPath) { 8 | return input; 9 | } 10 | return input.replace(/\\/g, '/'); 11 | }; 12 | 13 | export const registerNodeCiBabel = function(appDirectory: string, only: string[]): void { 14 | const babelOptions: IGetBabelOptions = { 15 | isTypeScript: true, 16 | isProduction: true, 17 | }; 18 | require('@babel/register')({ 19 | presets: [[babel, babelOptions]], 20 | extensions: ['.es6', '.es', '.jsx', '.js', '.mjs', '.ts', '.tsx'], 21 | only: only.map((file) => slash(join(appDirectory, file))), 22 | babelrc: false, 23 | cache: false, 24 | }); 25 | }; 26 | -------------------------------------------------------------------------------- /packages/hull-utils/src/startStaticServer.ts: -------------------------------------------------------------------------------- 1 | 2 | import Koa from 'koa'; 3 | import koaStatic from 'koa-static'; 4 | import history from 'koa2-connect-history-api-fallback'; 5 | import { log } from './log'; 6 | 7 | interface InStartStaticServer{ 8 | port: number|string; 9 | assetsRoot: string; 10 | maxAge: number; 11 | isUseGzip: boolean; 12 | } 13 | 14 | export const startStaticServer = (opts: InStartStaticServer) => { 15 | const app = new Koa(); 16 | app.use( 17 | history({ 18 | disableDotRule: true, 19 | verbose: true, 20 | logger: () => null, 21 | htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'], 22 | }), 23 | ); 24 | app.use( 25 | koaStatic(opts.assetsRoot, { 26 | maxage: opts.maxAge, 27 | gzip: opts.isUseGzip, 28 | extensions: ['html'], 29 | }), 30 | ); 31 | app.listen(opts.port, () => { 32 | log.success(`server is running at http://localhost:${opts.port}`); 33 | }); 34 | }; 35 | -------------------------------------------------------------------------------- /packages/hull-utils/src/usePort.ts: -------------------------------------------------------------------------------- 1 | import detect from 'detect-port-alt'; 2 | import { log } from './log'; 3 | 4 | export const checkPort = async(defaultPort: number) => { 5 | const port = await detect(defaultPort); 6 | if(port !== defaultPort){ 7 | log.error(`port: ${defaultPort} is running!`); 8 | return false; 9 | } 10 | return true; 11 | }; 12 | 13 | export const choosePort = async(defaultPort: number) => { 14 | const port = await detect(defaultPort); 15 | if(port !== defaultPort){ 16 | log.warn(`port: ${defaultPort} is running! ${port} instead!`); 17 | } 18 | return port; 19 | }; 20 | -------------------------------------------------------------------------------- /packages/hull-utils/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "sourceMap": true, 8 | "resolveJsonModule": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "skipDefaultLibCheck": false, 12 | "declaration": true, 13 | "outDir": "./dist", 14 | "rootDir": "./src", 15 | }, 16 | } -------------------------------------------------------------------------------- /packages/vite-plugin-babel-plugins/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | CHANGELOG.md 3 | tsconfig.json -------------------------------------------------------------------------------- /packages/vite-plugin-babel-plugins/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 0.8.0 (2022-11-17) 7 | 8 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 9 | 10 | 11 | 12 | 13 | 14 | ## 0.7.0 (2022-11-17) 15 | 16 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 17 | 18 | 19 | 20 | 21 | 22 | ## 0.6.0 (2022-11-17) 23 | 24 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 25 | 26 | 27 | 28 | 29 | 30 | ## 0.5.0 (2022-11-16) 31 | 32 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 33 | 34 | 35 | 36 | 37 | 38 | ## 0.4.0 (2022-11-14) 39 | 40 | * feat: extraBabelPresets for vite ([0ddac97](https://github.com/luoguoxiong/hulljs/commit/0ddac97)) 41 | 42 | 43 | 44 | 45 | 46 | ## 0.3.0 (2022-11-07) 47 | 48 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 49 | 50 | 51 | 52 | 53 | 54 | ## 0.2.0 (2022-08-31) 55 | 56 | * v0.0.1 ([abb7235](https://github.com/luoguoxiong/hulljs/commit/abb7235)) 57 | * v0.0.1 ([9741168](https://github.com/luoguoxiong/hulljs/commit/9741168)) 58 | * v0.0.1 ([fd6dff8](https://github.com/luoguoxiong/hulljs/commit/fd6dff8)) 59 | * v0.0.1 ([7bdb68f](https://github.com/luoguoxiong/hulljs/commit/7bdb68f)) 60 | * v0.0.1 ([0d7b9a0](https://github.com/luoguoxiong/hulljs/commit/0d7b9a0)) 61 | * v0.0.1 ([23a8219](https://github.com/luoguoxiong/hulljs/commit/23a8219)) 62 | * v0.0.1 ([2e7d627](https://github.com/luoguoxiong/hulljs/commit/2e7d627)) 63 | * v0.0.1-alpha.0 ([2bee034](https://github.com/luoguoxiong/hulljs/commit/2bee034)) 64 | * v0.0.1-alpha.0 ([91ec57e](https://github.com/luoguoxiong/hulljs/commit/91ec57e)) 65 | * v0.0.2 ([484bbd2](https://github.com/luoguoxiong/hulljs/commit/484bbd2)) 66 | * v0.0.2 ([93bde13](https://github.com/luoguoxiong/hulljs/commit/93bde13)) 67 | * v0.0.2 ([5869178](https://github.com/luoguoxiong/hulljs/commit/5869178)) 68 | * v0.0.2 ([c02f578](https://github.com/luoguoxiong/hulljs/commit/c02f578)) 69 | * v0.0.2-alpha.0 ([92972ca](https://github.com/luoguoxiong/hulljs/commit/92972ca)) 70 | * v0.0.4 ([64c2b6a](https://github.com/luoguoxiong/hulljs/commit/64c2b6a)) 71 | * v0.0.5 ([a332989](https://github.com/luoguoxiong/hulljs/commit/a332989)) 72 | * v0.0.6 ([45d2cdc](https://github.com/luoguoxiong/hulljs/commit/45d2cdc)) 73 | * v0.0.7 ([e4ab4fd](https://github.com/luoguoxiong/hulljs/commit/e4ab4fd)) 74 | * v0.0.8 ([b8131c9](https://github.com/luoguoxiong/hulljs/commit/b8131c9)) 75 | * v0.0.9 ([3c57a80](https://github.com/luoguoxiong/hulljs/commit/3c57a80)) 76 | * v0.1.0 ([da199ef](https://github.com/luoguoxiong/hulljs/commit/da199ef)) 77 | * v0.1.0 ([1e16cfc](https://github.com/luoguoxiong/hulljs/commit/1e16cfc)) 78 | * v0.1.0 ([9857d8a](https://github.com/luoguoxiong/hulljs/commit/9857d8a)) 79 | * v0.1.0 ([ef972e3](https://github.com/luoguoxiong/hulljs/commit/ef972e3)) 80 | * v0.1.0 ([3ac3e8b](https://github.com/luoguoxiong/hulljs/commit/3ac3e8b)) 81 | * v0.1.0 ([5e6c390](https://github.com/luoguoxiong/hulljs/commit/5e6c390)) 82 | * v0.1.0-alpha.0 ([23089e0](https://github.com/luoguoxiong/hulljs/commit/23089e0)) 83 | * v0.2.0 ([218cbd6](https://github.com/luoguoxiong/hulljs/commit/218cbd6)) 84 | * feat: 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407)) 85 | * feat: build ([e0c8bc4](https://github.com/luoguoxiong/hulljs/commit/e0c8bc4)) 86 | * feat: cli ([8110675](https://github.com/luoguoxiong/hulljs/commit/8110675)) 87 | * feat: cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6)) 88 | * feat: ok ([824478b](https://github.com/luoguoxiong/hulljs/commit/824478b)) 89 | * feat: test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af)) 90 | * feat: test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701c)) 91 | * feat: test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cd)) 92 | * feat: test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da)) 93 | * feat: test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c)) 94 | * feat: test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43)) 95 | * feat: test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f59250)) 96 | * feat: tst ([ce90f17](https://github.com/luoguoxiong/hulljs/commit/ce90f17)) 97 | * feat: update vite version ([3fea53c](https://github.com/luoguoxiong/hulljs/commit/3fea53c)) 98 | * fix: add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b2)) 99 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 100 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 101 | * fix: vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec72)) 102 | * chore(build): release ([fa1ac7e](https://github.com/luoguoxiong/hulljs/commit/fa1ac7e)) 103 | 104 | 105 | 106 | 107 | 108 | ## 0.1.0 (2022-07-28) 109 | 110 | * feat: update vite version ([3fea53c](https://github.com/luoguoxiong/hulljs/commit/3fea53c)) 111 | 112 | 113 | 114 | 115 | 116 | ## 0.0.9 (2022-06-16) 117 | 118 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 119 | 120 | 121 | 122 | 123 | 124 | ## 0.0.8 (2022-06-12) 125 | 126 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 127 | 128 | 129 | 130 | 131 | 132 | ## 0.0.7 (2022-06-12) 133 | 134 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 135 | 136 | 137 | 138 | 139 | 140 | ## 0.0.6 (2022-06-11) 141 | 142 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 143 | 144 | 145 | 146 | 147 | 148 | ## 0.0.5 (2022-06-11) 149 | 150 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 151 | 152 | 153 | 154 | 155 | 156 | ## 0.0.4 (2022-06-11) 157 | 158 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 159 | 160 | 161 | 162 | 163 | 164 | ## 0.0.3 (2022-06-11) 165 | 166 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 167 | 168 | 169 | 170 | 171 | 172 | ## [0.1.0](https://github.com/luoguoxiong/hulljs/compare/v0.0.3...v0.1.0) (2022-06-11) 173 | 174 | 175 | ### ✨ Features | 新功能 176 | 177 | * tst ([ce90f17](https://github.com/luoguoxiong/hulljs/commit/ce90f17f2beccd68a35cd5c908b05e15d87c1fd4)) 178 | 179 | 180 | ### 🐛 Bug Fixes | Bug 修复 181 | 182 | * add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b27e89bef094a0d7f3ade77122395a78bc0)) 183 | 184 | 185 | 186 | ## 0.1.0 (2022-06-10) 187 | 188 | 189 | ### 🐛 Bug Fixes | Bug 修复 190 | 191 | * vue3 tsx error ([fb5ec72](https://github.com/luoguoxiong/hulljs/commit/fb5ec7273b817f76ad359cfb8e9dabbb0eed7f04)) 192 | 193 | 194 | ### ✨ Features | 新功能 195 | 196 | * 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407fcaea1153ff421c41ead174539be99b9b)) 197 | * build ([e0c8bc4](https://github.com/luoguoxiong/hulljs/commit/e0c8bc40d475ca5173fe3e86a016b89d0c59b628)) 198 | * cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6e44439cb94d1080cc3e0ee6556271383c)) 199 | * test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af4f4a0fac7ce23bf0e3aa89e4577d9073b)) 200 | * test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701cb048f668ff4ec2d1ee1cb21e8ef87f930)) 201 | * test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cdcdbdb51c0a09f54b980e19320e94eb02c)) 202 | * test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da4ad397f984352294fd4c66e994b35a74f)) 203 | * test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c0e6d9e1fbcc37bf3a5d659978c81289b0)) 204 | * test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43edde66d27b8d1eaed0fecd65d9b812587)) 205 | * test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f592508321fab77b739d9977e293b49063fb173)) 206 | 207 | 208 | 209 | ## [0.2.0](https://github.com/luoguoxiong/hulljs/compare/v0.1.0...v0.2.0) (2022-06-10) 210 | 211 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 212 | 213 | 214 | 215 | 216 | 217 | 218 | # [0.1.0](https://github.com/projects/luoguoxiong/repos/hulljs/compare/diff?targetBranch=refs%2Ftags%2Fv0.0.1&sourceBranch=refs%2Ftags%2Fv0.1.0) (2022-06-10) 219 | 220 | **Note:** Version bump only for package @hulljs/vite-plugin-babel-plugins 221 | -------------------------------------------------------------------------------- /packages/vite-plugin-babel-plugins/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hulljs/vite-plugin-babel-plugins", 3 | "version": "0.8.0", 4 | "type": "commonjs", 5 | "description": "vite 使用babel plugins", 6 | "main": "./dist/index.js", 7 | "types": "./dist/index.d.js", 8 | "scripts": { 9 | "build": "tsc", 10 | "watch": "tsc -w" 11 | }, 12 | "author": "", 13 | "license": "ISC", 14 | "dependencies": { 15 | "@babel/core": "7.12.3" 16 | }, 17 | "peerDependencies": { 18 | "vite": ">=3.0.0" 19 | }, 20 | "devDependencies": { 21 | "typescript": "^4.6.4" 22 | }, 23 | "publishConfig": { 24 | "access": "public" 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /packages/vite-plugin-babel-plugins/src/global.d.ts: -------------------------------------------------------------------------------- 1 | declare module '@babel/core' 2 | -------------------------------------------------------------------------------- /packages/vite-plugin-babel-plugins/src/index.ts: -------------------------------------------------------------------------------- 1 | import { transform } from '@babel/core'; 2 | import type { PluginOption } from 'vite'; 3 | function useViteBabelPlugins(plugins?: any[], presets?: any[]): PluginOption { 4 | 5 | return { 6 | name: 'vite-plugin-babel-plugins', 7 | enforce: 'post', 8 | async transform(code: string, id: string) { 9 | 10 | if (/\.(js|mjs|jsx|ts|tsx)$/.test(id) && !/node_modules\/vite/.test(id)) { 11 | plugins = plugins || []; 12 | const result = await transform(code, { 13 | ast: true, 14 | plugins, 15 | presets, 16 | sourceFileName: id, 17 | }); 18 | 19 | return { 20 | code: result.code as string, 21 | map: result.map, 22 | }; 23 | } 24 | }, 25 | }; 26 | } 27 | 28 | export default useViteBabelPlugins; 29 | -------------------------------------------------------------------------------- /packages/vite-plugin-babel-plugins/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "sourceMap": true, 8 | "resolveJsonModule": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "skipDefaultLibCheck": false, 12 | "declaration": true, 13 | "outDir": "./dist", 14 | "rootDir": "./src", 15 | "baseUrl": ".", 16 | "paths": { 17 | "@/*": ["./*"] 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /packages/vite-plugin-html/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | CHANGELOG.md 3 | tsconfig.json -------------------------------------------------------------------------------- /packages/vite-plugin-html/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## 0.8.0 (2022-11-17) 7 | 8 | **Note:** Version bump only for package @hulljs/vite-plugin-html 9 | 10 | 11 | 12 | 13 | 14 | ## 0.7.0 (2022-11-17) 15 | 16 | **Note:** Version bump only for package @hulljs/vite-plugin-html 17 | 18 | 19 | 20 | 21 | 22 | ## 0.6.0 (2022-11-17) 23 | 24 | **Note:** Version bump only for package @hulljs/vite-plugin-html 25 | 26 | 27 | 28 | 29 | 30 | ## 0.5.0 (2022-11-16) 31 | 32 | **Note:** Version bump only for package @hulljs/vite-plugin-html 33 | 34 | 35 | 36 | 37 | 38 | ## 0.4.0 (2022-11-14) 39 | 40 | **Note:** Version bump only for package @hulljs/vite-plugin-html 41 | 42 | 43 | 44 | 45 | 46 | ## 0.3.0 (2022-11-07) 47 | 48 | **Note:** Version bump only for package @hulljs/vite-plugin-html 49 | 50 | 51 | 52 | 53 | 54 | ## 0.2.0 (2022-08-31) 55 | 56 | * v0.0.1 ([abb7235](https://github.com/luoguoxiong/hulljs/commit/abb7235)) 57 | * v0.0.1 ([9741168](https://github.com/luoguoxiong/hulljs/commit/9741168)) 58 | * v0.0.1 ([fd6dff8](https://github.com/luoguoxiong/hulljs/commit/fd6dff8)) 59 | * v0.0.1 ([7bdb68f](https://github.com/luoguoxiong/hulljs/commit/7bdb68f)) 60 | * v0.0.1 ([0d7b9a0](https://github.com/luoguoxiong/hulljs/commit/0d7b9a0)) 61 | * v0.0.1 ([23a8219](https://github.com/luoguoxiong/hulljs/commit/23a8219)) 62 | * v0.0.1 ([2e7d627](https://github.com/luoguoxiong/hulljs/commit/2e7d627)) 63 | * v0.0.1-alpha.0 ([2bee034](https://github.com/luoguoxiong/hulljs/commit/2bee034)) 64 | * v0.0.1-alpha.0 ([91ec57e](https://github.com/luoguoxiong/hulljs/commit/91ec57e)) 65 | * v0.0.2 ([484bbd2](https://github.com/luoguoxiong/hulljs/commit/484bbd2)) 66 | * v0.0.2 ([93bde13](https://github.com/luoguoxiong/hulljs/commit/93bde13)) 67 | * v0.0.2 ([5869178](https://github.com/luoguoxiong/hulljs/commit/5869178)) 68 | * v0.0.2 ([c02f578](https://github.com/luoguoxiong/hulljs/commit/c02f578)) 69 | * v0.0.2-alpha.0 ([92972ca](https://github.com/luoguoxiong/hulljs/commit/92972ca)) 70 | * v0.0.4 ([64c2b6a](https://github.com/luoguoxiong/hulljs/commit/64c2b6a)) 71 | * v0.0.5 ([a332989](https://github.com/luoguoxiong/hulljs/commit/a332989)) 72 | * v0.0.6 ([45d2cdc](https://github.com/luoguoxiong/hulljs/commit/45d2cdc)) 73 | * v0.0.7 ([e4ab4fd](https://github.com/luoguoxiong/hulljs/commit/e4ab4fd)) 74 | * v0.0.8 ([b8131c9](https://github.com/luoguoxiong/hulljs/commit/b8131c9)) 75 | * v0.0.9 ([3c57a80](https://github.com/luoguoxiong/hulljs/commit/3c57a80)) 76 | * v0.1.0 ([da199ef](https://github.com/luoguoxiong/hulljs/commit/da199ef)) 77 | * v0.1.0 ([1e16cfc](https://github.com/luoguoxiong/hulljs/commit/1e16cfc)) 78 | * v0.1.0 ([9857d8a](https://github.com/luoguoxiong/hulljs/commit/9857d8a)) 79 | * v0.1.0 ([ef972e3](https://github.com/luoguoxiong/hulljs/commit/ef972e3)) 80 | * v0.1.0 ([3ac3e8b](https://github.com/luoguoxiong/hulljs/commit/3ac3e8b)) 81 | * v0.1.0 ([5e6c390](https://github.com/luoguoxiong/hulljs/commit/5e6c390)) 82 | * v0.1.0-alpha.0 ([23089e0](https://github.com/luoguoxiong/hulljs/commit/23089e0)) 83 | * v0.2.0 ([218cbd6](https://github.com/luoguoxiong/hulljs/commit/218cbd6)) 84 | * feat: 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407)) 85 | * feat: build ([e0c8bc4](https://github.com/luoguoxiong/hulljs/commit/e0c8bc4)) 86 | * feat: cli ([8110675](https://github.com/luoguoxiong/hulljs/commit/8110675)) 87 | * feat: cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6)) 88 | * feat: ok ([824478b](https://github.com/luoguoxiong/hulljs/commit/824478b)) 89 | * feat: test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af)) 90 | * feat: test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701c)) 91 | * feat: test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cd)) 92 | * feat: test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da)) 93 | * feat: test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c)) 94 | * feat: test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43)) 95 | * feat: test ([7126dd7](https://github.com/luoguoxiong/hulljs/commit/7126dd7)) 96 | * feat: test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f59250)) 97 | * feat: update vite version ([3fea53c](https://github.com/luoguoxiong/hulljs/commit/3fea53c)) 98 | * feat: vite complete ([12fbe4e](https://github.com/luoguoxiong/hulljs/commit/12fbe4e)) 99 | * fix: add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b2)) 100 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 101 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 102 | * chore(build): release ([fa1ac7e](https://github.com/luoguoxiong/hulljs/commit/fa1ac7e)) 103 | * docs: 晚上文档 ([ad6c918](https://github.com/luoguoxiong/hulljs/commit/ad6c918)) 104 | 105 | 106 | 107 | 108 | 109 | ## 0.1.0 (2022-07-28) 110 | 111 | * feat: update vite version ([3fea53c](https://github.com/luoguoxiong/hulljs/commit/3fea53c)) 112 | 113 | 114 | 115 | 116 | 117 | ## 0.0.9 (2022-06-16) 118 | 119 | **Note:** Version bump only for package @hulljs/vite-plugin-html 120 | 121 | 122 | 123 | 124 | 125 | ## 0.0.8 (2022-06-12) 126 | 127 | * fix: npmignore ([e8833f2](https://github.com/luoguoxiong/hulljs/commit/e8833f2)) 128 | 129 | 130 | 131 | 132 | 133 | ## 0.0.7 (2022-06-12) 134 | 135 | **Note:** Version bump only for package @hulljs/vite-plugin-html 136 | 137 | 138 | 139 | 140 | 141 | ## 0.0.6 (2022-06-11) 142 | 143 | **Note:** Version bump only for package @hulljs/vite-plugin-html 144 | 145 | 146 | 147 | 148 | 149 | ## 0.0.5 (2022-06-11) 150 | 151 | **Note:** Version bump only for package @hulljs/vite-plugin-html 152 | 153 | 154 | 155 | 156 | 157 | ## 0.0.4 (2022-06-11) 158 | 159 | * fix: change cli ([716dc6c](https://github.com/luoguoxiong/hulljs/commit/716dc6c)) 160 | 161 | 162 | 163 | 164 | 165 | ## 0.0.3 (2022-06-11) 166 | 167 | **Note:** Version bump only for package @hulljs/vite-plugin-html 168 | 169 | 170 | 171 | 172 | 173 | ## [0.1.0](https://github.com/luoguoxiong/hulljs/compare/v0.0.3...v0.1.0) (2022-06-11) 174 | 175 | 176 | ### 🐛 Bug Fixes | Bug 修复 177 | 178 | * add publishconfig ([d2d89b2](https://github.com/luoguoxiong/hulljs/commit/d2d89b27e89bef094a0d7f3ade77122395a78bc0)) 179 | 180 | 181 | 182 | ## 0.1.0 (2022-06-10) 183 | 184 | 185 | ### 📝 Documentation | 文档 186 | 187 | * 晚上文档 ([ad6c918](https://github.com/luoguoxiong/hulljs/commit/ad6c918b6899d1391b57b4fd295949fb6bc15bbe)) 188 | 189 | 190 | ### ✨ Features | 新功能 191 | 192 | * 优化build工具 ([a627407](https://github.com/luoguoxiong/hulljs/commit/a627407fcaea1153ff421c41ead174539be99b9b)) 193 | * build ([e0c8bc4](https://github.com/luoguoxiong/hulljs/commit/e0c8bc40d475ca5173fe3e86a016b89d0c59b628)) 194 | * cli ([1a47cd6](https://github.com/luoguoxiong/hulljs/commit/1a47cd6e44439cb94d1080cc3e0ee6556271383c)) 195 | * test ([73255af](https://github.com/luoguoxiong/hulljs/commit/73255af4f4a0fac7ce23bf0e3aa89e4577d9073b)) 196 | * test ([cbe701c](https://github.com/luoguoxiong/hulljs/commit/cbe701cb048f668ff4ec2d1ee1cb21e8ef87f930)) 197 | * test ([6c7a3cd](https://github.com/luoguoxiong/hulljs/commit/6c7a3cdcdbdb51c0a09f54b980e19320e94eb02c)) 198 | * test ([cf603da](https://github.com/luoguoxiong/hulljs/commit/cf603da4ad397f984352294fd4c66e994b35a74f)) 199 | * test ([136293c](https://github.com/luoguoxiong/hulljs/commit/136293c0e6d9e1fbcc37bf3a5d659978c81289b0)) 200 | * test ([6d59f43](https://github.com/luoguoxiong/hulljs/commit/6d59f43edde66d27b8d1eaed0fecd65d9b812587)) 201 | * test ([7126dd7](https://github.com/luoguoxiong/hulljs/commit/7126dd70765e17e4d0c3d16ac78dc82dd7a08c0e)) 202 | * test release ([1f59250](https://github.com/luoguoxiong/hulljs/commit/1f592508321fab77b739d9977e293b49063fb173)) 203 | * vite complete ([12fbe4e](https://github.com/luoguoxiong/hulljs/commit/12fbe4e43d2eca8c136baeeee66b1d90a0d0604c)) 204 | 205 | 206 | 207 | ## [0.2.0](https://github.com/luoguoxiong/hulljs/compare/v0.1.0...v0.2.0) (2022-06-10) 208 | 209 | **Note:** Version bump only for package @hulljs/vite-plugin-html 210 | 211 | 212 | 213 | 214 | 215 | 216 | # [0.1.0](https://github.com/projects/luoguoxiong/repos/hulljs/compare/diff?targetBranch=refs%2Ftags%2Fv0.0.1&sourceBranch=refs%2Ftags%2Fv0.1.0) (2022-06-10) 217 | 218 | **Note:** Version bump only for package @hulljs/vite-plugin-html 219 | -------------------------------------------------------------------------------- /packages/vite-plugin-html/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@hulljs/vite-plugin-html", 3 | "version": "0.8.0", 4 | "description": "vite-plugin-html", 5 | "bin": { 6 | "hull-build": "./dist/index.js" 7 | }, 8 | "main": "./dist/index.js", 9 | "types": "./dist/index.d.js", 10 | "scripts": { 11 | "build": "tsc", 12 | "watch": "tsc -w" 13 | }, 14 | "dependencies": { 15 | "@rollup/pluginutils": "^4.2.0", 16 | "connect-history-api-fallback": "^1.6.0", 17 | "ejs": "^3.1.6", 18 | "fs-extra": "^10.0.1", 19 | "html-minifier-terser": "^6.1.0", 20 | "node-html-parser": "^5.3.3", 21 | "pathe": "^0.2.0" 22 | }, 23 | "peerDependencies": { 24 | "vite": ">=3.0.0" 25 | }, 26 | "devDependencies": { 27 | "@babel/types": "^7.17.0", 28 | "@types/ejs": "^3.1.0", 29 | "@types/fs-extra": "^9.0.13", 30 | "@types/html-minifier-terser": "^6.1.0", 31 | "@types/node": "^17.0.21", 32 | "typescript": "^4.6.4", 33 | "vite": "3.0.3" 34 | }, 35 | "publishConfig": { 36 | "access": "public" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /packages/vite-plugin-html/src/htmlPlugin.ts: -------------------------------------------------------------------------------- 1 | import type { ResolvedConfig, PluginOption } from 'vite'; 2 | import { render } from 'ejs'; 3 | import { normalizePath } from 'vite'; 4 | import { parse } from 'node-html-parser'; 5 | import fs from 'fs-extra'; 6 | import path from 'pathe'; 7 | import history from 'connect-history-api-fallback'; 8 | import type { InjectOptions, UserOptions } from './typing'; 9 | 10 | 11 | const bodyInjectRE = /<\/body>/; 12 | 13 | export function createPlugin(userOptions: UserOptions): PluginOption { 14 | const { 15 | entry, 16 | template, 17 | } = userOptions; 18 | 19 | let viteConfig: ResolvedConfig; 20 | 21 | let isInRoot = false; 22 | 23 | try { 24 | return { 25 | name: 'vite:vite-plugin-html', 26 | enforce: 'pre', 27 | configResolved(resolvedConfig) { 28 | viteConfig = resolvedConfig; 29 | isInRoot = fs.existsSync(path.join(resolvedConfig.root, 'index.html')); 30 | if(!isInRoot && viteConfig.command === 'build' ){ 31 | fs.copyFile(template, path.join(resolvedConfig.root, 'index.html')); 32 | } 33 | }, 34 | 35 | configureServer(server) { 36 | server.middlewares.use( 37 | history({ 38 | index: `/${path.relative(viteConfig.root, template)}`, 39 | htmlAcceptHeaders: ['text/html', 'application/xhtml+xml'], 40 | }) as any, 41 | ); 42 | }, 43 | 44 | transformIndexHtml: { 45 | enforce: 'pre', 46 | async transform(html) { 47 | const injectOptions = userOptions.inject || {}; 48 | const _html = await renderHtml(html, { 49 | injectOptions, 50 | viteConfig, 51 | entry, 52 | }); 53 | 54 | return { 55 | html: _html, 56 | tags: [], 57 | }; 58 | }, 59 | }, 60 | 61 | async closeBundle(){ 62 | if(!isInRoot){ 63 | fs.removeSync(path.join(viteConfig.root, 'index.html')); 64 | } 65 | }, 66 | }; 67 | } catch (error: any) { 68 | throw Error(error); 69 | } 70 | } 71 | 72 | export async function renderHtml( 73 | html: string, 74 | config: { 75 | injectOptions: InjectOptions; 76 | viteConfig: ResolvedConfig; 77 | entry?: string; 78 | }, 79 | ) { 80 | const { injectOptions, entry } = config; 81 | 82 | const ejsData: Record = { 83 | htmlWebpackPlugin: { 84 | options: { 85 | ...injectOptions, 86 | }, 87 | }, 88 | }; 89 | let result = await render(html, ejsData); 90 | 91 | if (entry) { 92 | result = removeEntryScript(result ); 93 | result = result.replace( 94 | bodyInjectRE, 95 | `\n`, 98 | ); 99 | } 100 | return result; 101 | } 102 | 103 | export function removeEntryScript(html: string) { 104 | if (!html) { 105 | return html; 106 | } 107 | 108 | const root = parse(html); 109 | const scriptNodes = root.querySelectorAll('script[type=module]') || []; 110 | const removedNode: string[] = []; 111 | scriptNodes.forEach((item) => { 112 | removedNode.push(item.toString()); 113 | item.parentNode.removeChild(item); 114 | }); 115 | return root.toString(); 116 | } 117 | -------------------------------------------------------------------------------- /packages/vite-plugin-html/src/index.ts: -------------------------------------------------------------------------------- 1 | import type { PluginOption } from 'vite'; 2 | import consola from 'consola'; 3 | import type { UserOptions } from './typing'; 4 | import { createPlugin } from './htmlPlugin'; 5 | import { createMinifyHtmlPlugin } from './minifyHtml'; 6 | 7 | consola.wrapConsole(); 8 | 9 | export function createHtmlPlugin( 10 | userOptions: UserOptions, 11 | ): PluginOption[] { 12 | return [createPlugin(userOptions), createMinifyHtmlPlugin(userOptions)]; 13 | } 14 | -------------------------------------------------------------------------------- /packages/vite-plugin-html/src/minifyHtml.ts: -------------------------------------------------------------------------------- 1 | import type { PluginOption } from 'vite'; 2 | import type { Options as MinifyOptions } from 'html-minifier-terser'; 3 | import { minify as minifyFn } from 'html-minifier-terser'; 4 | import { createFilter } from '@rollup/pluginutils'; 5 | 6 | export const htmlFilter = createFilter(['**/*.html']); 7 | 8 | 9 | function getOptions(minify: boolean): MinifyOptions { 10 | return { 11 | collapseWhitespace: minify, 12 | keepClosingSlash: minify, 13 | removeComments: minify, 14 | removeRedundantAttributes: minify, 15 | removeScriptTypeAttributes: minify, 16 | removeStyleLinkTypeAttributes: minify, 17 | useShortDoctype: minify, 18 | minifyCSS: minify, 19 | }; 20 | } 21 | 22 | export async function minifyHtml( 23 | html: string, 24 | minify: boolean | MinifyOptions, 25 | ) { 26 | if (typeof minify === 'boolean' && !minify) { 27 | return html; 28 | } 29 | 30 | let minifyOptions: boolean | MinifyOptions = minify; 31 | 32 | if (typeof minify === 'boolean' && minify) { 33 | minifyOptions = getOptions(minify); 34 | } 35 | 36 | return await minifyFn(html, minifyOptions as MinifyOptions); 37 | } 38 | 39 | export function createMinifyHtmlPlugin({ 40 | minify = true, 41 | }: any): PluginOption { 42 | return { 43 | name: 'vite:minify-html', 44 | enforce: 'post', 45 | async generateBundle(_, outBundle) { 46 | if (minify) { 47 | for (const bundle of Object.values(outBundle)) { 48 | if ( 49 | bundle.type === 'asset' && 50 | htmlFilter(bundle.fileName) && 51 | typeof bundle.source === 'string' 52 | ) { 53 | bundle.source = await minifyHtml(bundle.source, minify); 54 | } 55 | } 56 | } 57 | }, 58 | }; 59 | } 60 | -------------------------------------------------------------------------------- /packages/vite-plugin-html/src/typing.ts: -------------------------------------------------------------------------------- 1 | import type { Options as MinifyOptions } from 'html-minifier-terser'; 2 | 3 | export type Entry = string | Record 4 | 5 | export type InjectOptions = Record 6 | 7 | export interface UserOptions { 8 | /** 9 | * @description Minimize options 10 | */ 11 | minify?: MinifyOptions | boolean; 12 | 13 | /** 14 | * page entry 15 | */ 16 | entry: string; 17 | 18 | /** 19 | * template path 20 | */ 21 | template: string; 22 | 23 | /** 24 | * @description inject options 25 | */ 26 | inject?: InjectOptions; 27 | 28 | /** 29 | * output warning log 30 | * @default false 31 | */ 32 | verbose?: boolean; 33 | } 34 | -------------------------------------------------------------------------------- /packages/vite-plugin-html/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "esnext", 4 | "module": "CommonJS", 5 | "moduleResolution": "node", 6 | "strict": true, 7 | "sourceMap": true, 8 | "resolveJsonModule": true, 9 | "esModuleInterop": true, 10 | "skipLibCheck": true, 11 | "skipDefaultLibCheck": false, 12 | "declaration": true, 13 | "outDir": "./dist", 14 | "rootDir": "./src", 15 | }, 16 | } -------------------------------------------------------------------------------- /public/images/code.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoguoxiong/hulljs/191b09d78725afa0d40cc2d8cefacba92eff8d6c/public/images/code.jpg -------------------------------------------------------------------------------- /public/images/init.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoguoxiong/hulljs/191b09d78725afa0d40cc2d8cefacba92eff8d6c/public/images/init.png -------------------------------------------------------------------------------- /public/images/logo.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoguoxiong/hulljs/191b09d78725afa0d40cc2d8cefacba92eff8d6c/public/images/logo.ico -------------------------------------------------------------------------------- /public/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoguoxiong/hulljs/191b09d78725afa0d40cc2d8cefacba92eff8d6c/public/images/logo.png -------------------------------------------------------------------------------- /public/images/pics.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/luoguoxiong/hulljs/191b09d78725afa0d40cc2d8cefacba92eff8d6c/public/images/pics.jpg -------------------------------------------------------------------------------- /script/install.sh: -------------------------------------------------------------------------------- 1 | # 确保脚本抛出遇到的错误 2 | set -e 3 | cnpm install 4 | 5 | npm run bootstrap -------------------------------------------------------------------------------- /script/release.sh: -------------------------------------------------------------------------------- 1 | # 确保脚本抛出遇到的错误 2 | set -e 3 | 4 | # 读取当前分支 5 | branch=`git symbolic-ref --short HEAD` 6 | 7 | if [ "$branch" = "master" ]; then 8 | 9 | npm run version 10 | 11 | git push origin master 12 | 13 | git push --follow-tags origin master 14 | 15 | else 16 | 17 | echo -e "\033[31m 只能在 master 或者 dev 分支上执行 yarn release! \033[0m" 18 | fi -------------------------------------------------------------------------------- /test.md: -------------------------------------------------------------------------------- 1 | npm run version -- --prerelease alpha --------------------------------------------------------------------------------