@kne/cra-template-components

0.1.4 • Public • Published

cra-template-components

初始化一个远程组件项目

安装

npx create-react-app project-name --template=@kne/cra-template-components

注意

由于cra限制,模板不能拿到project-name,初始化完成后需要再手动进行一些修改,后期会替换掉cra

  1. package.json

    删除

        {"private":true}

    修改

    {"name": "project-name"}

    {"name": "@kne/project-name"}

    将components-name替换为实际项目名

    {
      "scripts": {
        "build": "cross-env COMPONENTS_NAME=components-name MODULES_DEV_PUBLIC_URL=/components-name  craco build"
      }
    }
  2. src/preset.js 替换其中的components-name为实际项目名

        remoteLoaderPreset({
            remotes: {
                default: componentsCoreRemote,
                'components-core': componentsCoreRemote,
                'components-name': process.env.NODE_ENV === 'development' ? {
                    remote: 'components-name', url: '/', tpl: '{{url}}'
                } : {
                    remote: 'components-name',
                    url: 'https://registry.npmmirror.com',
                    tpl: '{{url}}/@kne%2f{{remote}}/{{version}}/files/build',
                    defaultVersion: process.env.DEFAULT_VERSION
                }
            }
        });
  3. .github/workflows/publish.yml

    将packageName替换为package.json中的name

    - name: Sync To Cnpm
      run: npm i -g cnpm && cnpm sync packageName

Package Sidebar

Install

npm i @kne/cra-template-components

Weekly Downloads

0

Version

0.1.4

License

MIT

Unpacked Size

37.7 kB

Total Files

30

Last publish

Collaborators

  • metacoo
  • yangwang123456
  • juliewang
  • lingtong