0.23.6 • Published 4 months ago

cja-phoenix v0.23.6

Weekly downloads
-
License
-
Repository
-
Last release
4 months ago

CJA Phoenix

Setup

# install dependencies
npm install

# start the doc app, great for testing components
npm run story:dev

# build the doc app for deployment
npm run story:build

# build the library, available under dist
npm run build

# build the library for use with npm link
npm run build:link

# builds the library for publishing, requires a version bump
npm run publish:lib

Develop and test locally

The best way to develop and test your component is by creating stories in src/histoire folder.

If you want to test the library in your Vue3 app locally:

  • In the root folder of this library, run npm run build:link. This will build the library for development and create a symbolic link to the library.
  • In the package.json of the client app add the script: reload: npm link cja-phoenix && npm run serve, this will grab the symbolic link created by running npm run build:link.
  • You can now import cja-phoenix in your client app.
  • The library can be installed on your app with the App.use() function

If you made changes to the library, you will need to run npm run build:link on Phoenix's side and npm run reload on the client app's side.

It is advised to add the script "reset:packages": "npm unlink cja-phoenix && npm i cja-phoenix@latest"to the client app in order to make the process of clearing the npm link and updating the cja-phoenix version easier. Simply run it after you have made your changes and published them, the script will automatically clean up the package lock file and reinstall the latest cja-phoenix version.

Publishing

After testing your developments and updating the documentation app, bump the version in package.json and run npm run publish

How it works

Components

The library is a Vue plugin. The install function in index.ts registers all components under components to Vue globaly.

The doc app itself is a client app of the library.

Utilities and constants

The library includes example utilities and constants. They are also exported in index.ts. The client app may use them as below:

<script lang="ts">
import { MyConstants, MyUtil } from 'cja-phoenix'

export default {
  data () {
    return {
      magicNum: MyConstants.MAGIC_NUM
    }
  },
  methods: {
    add (a:number, b:number) {
      return MyUtil.add(a, b)
    }
  }
}
</script>

Styling

Individual components have styles defined in its .vue file. They will be processed, combined and minified into dist/style.css, which is included in the exports list in package.json.

If you have library level styles shared by all components in the library, you may add them to src/assets/main.scss. This file is imported in index.ts, the processed styles are also included into dist/style.css.

The client app must import style.css in its entry file:

import "cja-phoenix/style";

Iconia

In order to edit the Iconia font access Icomoon and perform the required adaptations. If the current Iconia project is not loaded, use the import project tool with the assets/iconia/selection.json file. In order to properly generate the font svg file inputs should have outlined strokes. General rule, icons should have their size scaled up to the canvas and color removed through the edit function.

After editing the font, the types/Icon.ts file should be updated to include the new icon class names.

Third-party dependencies

Third-party libraries used by you library may bloat up the size of your library, if you simply add them to the dependencies in package.json.

The following are some strategies to reduce the size of your library:

Externalization

If you expect the client app of your library may also need the same dependency, you can externalize the dependency. For example, to exclude Vue from your library build artifact, in vite.config.ts, you can have

module.exports = defineConfig({
    rollupOptions: {
      external: ['vue']
    }
  }
})

The dependency to be externalized can be declared as a peer dependency in your library.

Nuxt Apps

The library is specially adapted to be used with nuxt apps and as such requires specific configurations.

Library Initialization

When attaching the library to the app, you must provide the use function with an options object containing urls for the image cdn, api url and if needed provider image url.

Standard Vue Apps

As development on the library progresses, the code has been adapted to cater to nuxt requirements and specific patterns. Nevertheless, if the library must be used on standalone vue apps, additional steps must be taken.

Importing SCSS variables

Add the following code to vue.config in order to import the library SCSS variables

css: {
  loaderOptions: {
    scss: {
      additionalData: `@use "cja-phoenix/variables" as *;`,
    },
  },
}

Type generation

In tsconfig.json, the following options instructs tsc to emit declaration (.d.ts files) only, as vite build handles the .js file generation. The generated .d.ts files are sent to dist/types folder.

"compilerOptions": {
  "declaration": true,
  "emitDeclarationOnly": true,
  "declarationDir": "./dist/types"
}

In package.json, the line below locates the generated types for library client.

"types": "./dist/types/index.d.ts",

In vite.config.ts, build.emptyOutDir is set to false and rimraf is used instead to remove the dist folder before the build. This is to avoid the dist/types folder generated by tsc being deleted when running vite build.

Configuration

TypeScript

In tsconfig.json, set the following as recommended by Vite (since esbuild is used). However, enabling this option leads to https://github.com/vitejs/vite/issues/5814. The workaround is to also enable compilerOptions.skipLibCheck.

"compilerOptions": {
  "isolatedModules": true
}

In tsconfig.json, set the following to address Issue #32. The solution is from https://github.com/johnsoncodehk/volar/discussions/592.

"compilerOptions": {
  "types": [
    "vite/client"
  ]
}

Dependencies

In package.json, Vue is declared in both peerDependencies and devDependencies. The former requires the client app to add these dependencies, and the later makes it easier to setup this library by simply running npm install.

0.23.6

4 months ago

0.23.5

5 months ago

0.23.4

5 months ago

0.23.3

5 months ago

0.23.2

5 months ago

0.22.6

5 months ago

0.23.1

5 months ago

0.23.0

5 months ago

0.21.1

5 months ago

0.21.0

5 months ago

0.22.5

5 months ago

0.22.4

5 months ago

0.22.3

5 months ago

0.22.2

5 months ago

0.22.1

5 months ago

0.22.0

5 months ago

0.20.1

6 months ago

0.20.0

6 months ago

0.20.2

6 months ago

0.19.29

6 months ago

0.19.24

6 months ago

0.19.25

6 months ago

0.19.26

6 months ago

0.19.27

6 months ago

0.19.28

6 months ago

0.19.22

6 months ago

0.19.21

6 months ago

0.19.20

6 months ago

0.19.18

7 months ago

0.19.19

7 months ago

0.19.16

7 months ago

0.19.17

7 months ago

0.19.14

7 months ago

0.19.15

7 months ago

0.19.12

7 months ago

0.19.13

7 months ago

0.19.8

7 months ago

0.19.9

7 months ago

0.19.6

7 months ago

0.19.7

7 months ago

0.19.11

7 months ago

0.19.10

7 months ago

0.18.3

8 months ago

0.18.4

8 months ago

0.18.5

8 months ago

0.18.6

8 months ago

0.19.0

8 months ago

0.19.1

8 months ago

0.19.2

8 months ago

0.19.3

8 months ago

0.19.4

8 months ago

0.19.5

8 months ago

0.18.1

8 months ago

0.18.2

8 months ago

0.18.0

8 months ago

0.17.0

8 months ago

0.17.1

8 months ago

0.16.0

9 months ago

0.15.6

9 months ago

0.15.4

9 months ago

0.15.5

9 months ago

0.15.3

9 months ago

0.14.39

10 months ago

0.14.41

10 months ago

0.14.40

10 months ago

0.15.0

10 months ago

0.15.1

9 months ago

0.15.2

9 months ago

0.14.31

11 months ago

0.14.35

10 months ago

0.14.34

10 months ago

0.14.33

11 months ago

0.14.32

11 months ago

0.14.38

10 months ago

0.14.37

10 months ago

0.14.36

10 months ago

0.14.28

11 months ago

0.14.29

11 months ago

0.14.30

11 months ago

0.14.24

11 months ago

0.14.27

11 months ago

0.14.26

11 months ago

0.14.25

11 months ago

0.14.23

12 months ago

0.14.22

12 months ago

0.14.21

12 months ago

0.14.17

12 months ago

0.14.19

12 months ago

0.14.18

12 months ago

0.14.20

12 months ago

0.14.16

12 months ago

0.14.15

12 months ago

0.14.14

12 months ago

0.14.13

12 months ago

0.14.12

12 months ago

0.14.11

12 months ago

0.14.7

1 year ago

0.14.8

1 year ago

0.14.9

1 year ago

0.14.5

1 year ago

0.14.6

1 year ago

0.14.2

1 year ago

0.14.3

1 year ago

0.14.4

1 year ago

0.14.0

1 year ago

0.14.1

1 year ago

0.13.2

1 year ago

0.13.3

1 year ago

0.13.1

1 year ago

0.13.0

1 year ago

0.12.0

1 year ago

0.11.1

1 year ago

0.10.0

1 year ago

0.9.0

1 year ago

0.8.2

1 year ago

0.8.1

1 year ago

0.8.0

1 year ago

0.7.43

1 year ago

0.7.39

1 year ago

0.7.40

1 year ago

0.7.42

1 year ago

0.7.41

1 year ago

0.7.38

1 year ago

0.7.37

1 year ago

0.7.35

1 year ago

0.7.36

1 year ago

0.7.33

1 year ago

0.7.32

1 year ago

0.7.34

1 year ago

0.7.31

1 year ago

0.7.30

1 year ago

0.7.29

1 year ago

0.7.28

1 year ago

0.7.27

1 year ago

0.7.26

1 year ago

0.7.25

1 year ago

0.7.24

1 year ago

0.7.23

2 years ago

0.7.22

2 years ago

0.7.21

2 years ago

0.7.20

2 years ago

0.7.19

2 years ago

0.7.18

2 years ago

0.7.17

2 years ago

0.7.16

2 years ago

0.7.15

2 years ago

0.7.14

2 years ago

0.7.13

2 years ago

0.3.0

2 years ago

0.7.2

2 years ago

0.3.6

2 years ago

0.7.1

2 years ago

0.3.5

2 years ago

0.7.4

2 years ago

0.7.3

2 years ago

0.3.7

2 years ago

0.5.0

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.7.0

2 years ago

0.3.4

2 years ago

0.5.1

2 years ago

0.3.3

2 years ago

0.7.11

2 years ago

0.7.10

2 years ago

0.7.9

2 years ago

0.7.12

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.8

2 years ago

0.7.7

2 years ago

0.6.3

2 years ago

0.6.2

2 years ago

0.6.4

2 years ago

0.4.0

2 years ago

0.6.1

2 years ago

0.6.0

2 years ago

0.2.24

2 years ago

0.2.23

2 years ago

0.2.22

2 years ago

0.2.21

2 years ago

0.2.20

2 years ago

0.2.19

2 years ago

0.2.18

2 years ago

0.2.17

2 years ago

0.2.16

2 years ago

0.2.15

2 years ago

0.2.14

2 years ago

0.2.13

2 years ago

0.2.12

2 years ago

0.2.11

2 years ago

0.2.10

2 years ago

0.2.7

2 years ago

0.2.6

2 years ago

0.2.9

2 years ago

0.2.8

2 years ago

0.2.5

2 years ago

0.2.4

2 years ago

0.2.1

2 years ago

0.2.3

2 years ago

0.2.2

2 years ago

0.1.0

2 years ago

0.1.1

2 years ago

0.0.13

2 years ago

0.0.14

2 years ago

0.0.15

2 years ago

0.0.10

2 years ago

0.0.11

2 years ago

0.0.12

2 years ago

0.0.9

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.8

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.1

2 years ago