|
| 1 | +## Atomico Starter Skit |
| 2 | + |
| 3 | +Hi, thanks for starting with Atomico js web components in this starter-kit you will find what you need to start with Atomico and if you have questions about Atomico I will gladly solve them through an [Issue](https://github.com/atomicojs/atomico/issues/new/choose), [Discord](https://discord.gg/7z3rNhmkNE) or [Twitter](https://twitter.com/atomicojs). |
| 4 | + |
| 5 | +[](https://twitter.com/atomicojs) |
| 6 | +[](https://discord.gg/7z3rNhmkNE) |
| 7 | +[](https://atomico.gitbook.io/doc/) |
| 8 | + |
| 9 | +Now what you have installed is a quick start kit based on Vite, which you can scale for your project, now to continue you must execute the following commands: |
| 10 | + |
| 11 | +1. `npm install` |
| 12 | +2. `npm start` : Initialize the development server |
| 13 | +3. `npm build` : Optional, Generate a build of your project from the html file [index.html](index.html). |
| 14 | + |
| 15 | +## Workspace |
| 16 | + |
| 17 | +### Recommended structure |
| 18 | + |
| 19 | +```bash |
| 20 | +src |
| 21 | + |- my-component |
| 22 | + | |- my-component.{js,jsx,ts,tsx} |
| 23 | + | |- my-component.test.js |
| 24 | + | |- README.md |
| 25 | + |- components.js # import all components |
| 26 | +``` |
| 27 | + |
| 28 | +> The `npm run create:component` command, will create a webcomponent with the recommended structure. |
| 29 | +
|
| 30 | +## Scripts |
| 31 | + |
| 32 | +### npm run create:component |
| 33 | + |
| 34 | +Create a new webcomponent inside src, according to the recommended structure. |
| 35 | + |
| 36 | +### npm run start |
| 37 | + |
| 38 | +initialize Vite server |
| 39 | + |
| 40 | +### npm run build |
| 41 | + |
| 42 | +package the app using de Vite |
| 43 | + |
| 44 | +### npm run test |
| 45 | + |
| 46 | +Run a test environment in watch mode, as configured in `vite.config.js`. |
| 47 | + |
| 48 | +### npm run coverage |
| 49 | + |
| 50 | +Run a test environment with coverage, as configured in `vite.config.js`. |
| 51 | + |
| 52 | +### npm run exports |
| 53 | + |
| 54 | +Allows you to export your project to npm, this command executes changes in package.json before exporting and the changes will be reverted once exported. |
| 55 | + |
| 56 | +temporary changes are: |
| 57 | + |
| 58 | +1. generation of the packages.json#exports |
| 59 | +2. generation of the pages.json#typesVersions |
| 60 | +3. Compilation of the files and generation of the types if the --types flag is used. |
| 61 | + |
| 62 | +## frequent questions |
| 63 | + |
| 64 | +### How to add postcss? |
| 65 | + |
| 66 | +`@atomico/vite`, allows to preprocess the css template string through postcss, to use this feature add in vite.config.js the following options: |
| 67 | + |
| 68 | +```js |
| 69 | +import atomico from "@atomico/vite"; |
| 70 | +import { defineConfig } from "vite"; |
| 71 | + |
| 72 | +export default defineConfig({ |
| 73 | + ... |
| 74 | + plugins: [ |
| 75 | + atomico({ |
| 76 | + cssLiterals: { postcss: true }, // 👈 CONFIGURATION TO ADD |
| 77 | + }), |
| 78 | + ], |
| 79 | +}); |
| 80 | +``` |
| 81 | + |
| 82 | +To use postcss at least 1 plugin is required. |
| 83 | + |
| 84 | +```json |
| 85 | +"postcss": { |
| 86 | + "plugins": { |
| 87 | + "postcss-import": {} |
| 88 | + } |
| 89 | +} |
| 90 | +``` |
| 91 | + |
| 92 | +### How to publish on github page? |
| 93 | + |
| 94 | +Add to `package.json#scripts.build`: |
| 95 | + |
| 96 | +```bash |
| 97 | +--outDir docs # modify the destination directory |
| 98 | +--base my-repo # github page folder |
| 99 | +``` |
0 commit comments