From 03b8f9d893e3a7351d5a5dfab126040f06f1c606 Mon Sep 17 00:00:00 2001 From: Ryan Christian <33403762+rschristian@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:20:36 -0500 Subject: [PATCH] v4 (#1647) * Chore: Updating html-webpack-plugin to v4 (#1608) * chore: Correcting changeset * feat: webpack v5 (#1645) * feat: webpack-v5 * test: Update tests * docs: Updating docs to reflect changes * chore: Removing optimize-plugin local patch * refactor: Determine CSS module by filename, not directory (#1714) * refactor: Determine CSS module by filename, not directory * docs: Adding changeset * refactor: Project creation pull from templates 'main' branch * test: Updating tests * revert: Accidentally removed log message * refactor: Extracting project creation out to own package (#1708) * refactor: Extracting out project creation to own package * docs: Adding changeset * refactor: Misc edits to common deps & workspace helper scripts * test: Fixing 'create' test suite * ci: Increase minimum Node version * chore: Fix typos * docs: Update ReadMe instructions * chore: Better (and untaken) package name * docs: Update changeset * test: Update 'create' test suite & build output hashes * docs: Expounding upon changeset * refactor: Drop Preact 8 support (#1716) * refactor: Drops support for Preact v8 * docs: Adding changeset * refactor: Switch to automatic runtime JSX transform (#1725) * refactor: Switch over to automatic runtime transform for JSX * test: Removing `h` imports from test suite * docs: Adding changeset * docs: Adding readme for create-cli (#1728) * docs: Adding readme for create-cli * feat: Initial publish * fix: Correcting broken readme links * refactor: Disable hashing ssr-build's css (#1733) * refactor: Disable hashing ssr-build's css * docs: Adding changeset * test: Fix unrelated change from altered template * refactor: Remove `--preload` flag (#1737) * refactor: Removes `--preload` flag & functionality * docs: Adding changeset * docs: Updating readme for removal of preload * refactor: Separate internal concepts of config and env (#1734) * refactor: Separate internal concepts of config and env * docs: Adding changeset * refactor: prune flags (#1752) * refactor: Revise inconsistent, unused, and deprecated flags * docs: Adding changeset * feat: Improved errors and warnings (#1758) * refactor: Better root error handling * refactor: Switch prerender plugin to be async for error gen * refactor: Simplify & improve compilation messages * refactor: Bump Node version, remove `src` arg in build & watch, and misc housekeeping (#1753) * refactor: Drop rimraf for built-in fs.rm * refactor: Drop src argument in build & watch cmds * refactor: Extract info cmd from CLI entrypoint * refactor: Remove update-notifier * refactor: Switch from fs.promises to fs/promises * docs: Adding changeset * refactor: Move EJS into user templates (`template.html`) (#1768) * refactor: Merging EJS templates and switcing preferred template extension to .ejs * test: Fixing test suite to reflect latest changes * chore: Cleaning * docs: Updating ReadMe * docs: Adding changeset * refactor: Add error message for <% preact.(head|body)End %> * chore: Publishing cli & create-cli * Refactor: Enable Prefresh by Default (#1772) * refactor: Enables HMR via Prefresh by default * docs: Adding changeset * test: Updating tests to reflect changes to templates * refactor: Remove Critters (perhaps temporarily) (#1778) * refactor: Remove Critters (perhaps temporarily) * docs: Adding changeset * chore: Publish v4.0.0-next.2 * refactor: Vendor Critters so that 7c811ac can be reverted (#1780) * docs: Remove CLI beta note from readme * docs: Bump minimum Node version listed in readme --- .changeset/cuddly-ducks-reply.md | 6 + .changeset/cyan-tomatoes-count.md | 11 + .changeset/great-dryers-cross.md | 9 + .changeset/hungry-peas-look.md | 9 + .changeset/lucky-lizards-drive.md | 5 + .changeset/metal-roses-flash.md | 7 + .changeset/poor-sloths-mate.md | 5 + .changeset/popular-zebras-yell.md | 5 + .changeset/quiet-eels-fix.md | 5 + .changeset/rude-walls-dress.md | 6 + .changeset/sweet-snakes-cheat.md | 12 + .changeset/tender-lamps-boil.md | 9 + .changeset/tiny-garlics-argue.md | 14 + .eslintignore | 1 + .eslintrc | 18 +- .github/workflows/ci.yml | 2 +- README.md | 89 +- jsconfig.json | 6 +- package.json | 7 +- packages/async-loader/async-legacy.js | 36 - packages/async-loader/index.js | 20 +- packages/async-loader/legacy.js | 8 - packages/async-loader/package.json | 3 +- packages/cli/babel/index.js | 52 - packages/cli/global.d.ts | 13 + packages/cli/package.json | 97 +- packages/cli/src/commands/build.js | 32 +- packages/cli/src/commands/create.js | 395 -- packages/cli/src/commands/index.js | 11 - packages/cli/src/commands/info.js | 18 + packages/cli/src/commands/watch.js | 13 +- packages/cli/src/constants.js | 44 - packages/cli/src/index.js | 98 +- packages/cli/src/lib/babel-config.js | 34 +- packages/cli/src/lib/entry.js | 18 +- packages/cli/src/lib/setup.js | 65 - .../src/lib/webpack/create-load-manifest.js | 69 - .../cli/src/lib/webpack/critters-plugin.js | 214 + packages/cli/src/lib/webpack/prerender.js | 15 +- packages/cli/src/lib/webpack/proxy-loader.js | 4 +- packages/cli/src/lib/webpack/push-manifest.js | 37 - .../cli/src/lib/webpack/render-html-plugin.js | 250 +- packages/cli/src/lib/webpack/run-webpack.js | 258 +- .../cli/src/lib/webpack/transform-config.js | 41 +- packages/cli/src/lib/webpack/utils.js | 16 - .../src/lib/webpack/webpack-base-config.js | 208 +- .../src/lib/webpack/webpack-client-config.js | 188 +- .../src/lib/webpack/webpack-server-config.js | 14 +- packages/cli/src/resources/body-end.ejs | 18 - packages/cli/src/resources/head-end.ejs | 12 - packages/cli/src/resources/static-app.json | 41 - packages/cli/src/resources/template.ejs | 27 + packages/cli/src/resources/template.html | 15 - packages/cli/src/util.js | 33 +- packages/cli/tests/build.test.js | 202 +- packages/cli/tests/client.test.js | 31 +- packages/cli/tests/config-formats.test.js | 8 +- packages/cli/tests/images/build.js | 226 +- packages/cli/tests/lib/cli.js | 37 +- packages/cli/tests/lib/output.js | 2 +- packages/cli/tests/lib/utils.js | 43 +- packages/cli/tests/service-worker.test.js | 14 +- .../css-auto-modules/components/index.js | 4 - .../css-auto-modules/components/style.css | 3 - .../tests/subjects/css-auto-modules/index.js | 14 - .../subjects/css-auto-modules/routes/index.js | 4 - .../css-auto-modules/routes/style.css | 3 - .../cli/tests/subjects/css-inline/index.js | 2 - .../cli/tests/subjects/css-modules/index.js | 11 + .../package.json | 0 .../global.css => css-modules/style.css} | 0 .../subjects/css-modules/style.module.css | 3 + .../subjects/css-sass/components/app/index.js | 11 - .../css-sass/components/app/style.scss | 3 - packages/cli/tests/subjects/css-sass/index.js | 17 +- .../tests/subjects/css-sass/style.module.sass | 2 + .../home.css => css-sass/style.module.scss} | 2 +- .../cli/tests/subjects/css-sass/style.sass | 2 + .../cli/tests/subjects/css-sass/style.scss | 3 + .../tests/subjects/custom-babelrc/.babelrc | 2 +- .../tests/subjects/custom-babelrc/index.js | 2 +- .../tests/subjects/custom-template/index.js | 2 - .../{template.html => template.ejs} | 10 +- .../tests/subjects/custom-webpack/index.js | 2 - .../subjects/custom-webpack/preact.config.js | 7 +- .../tests/subjects/location-patch/index.js | 2 - packages/cli/tests/subjects/minimal/index.js | 1 - .../subjects/multiple-config-files/index.js | 2 +- .../preactConfig/cjs/function.js | 9 +- .../preactConfig/cjs/object.js | 9 +- .../preactConfig/esm/function.js | 9 +- .../preactConfig/esm/object.js | 9 +- .../index.js | 2 +- .../routes/custom.js | 2 +- .../subjects/multiple-prerendering/index.js | 2 +- .../tests/subjects/preload-chunks/index.js | 24 - .../subjects/preload-chunks/package.json | 4 - .../subjects/preload-chunks/routes/base.js | 11 - .../subjects/preload-chunks/routes/home.js | 9 - .../preload-chunks/routes/route66.css | 3 - .../subjects/preload-chunks/routes/route66.js | 9 - .../preload-chunks/routes/route89.css | 3 - .../subjects/preload-chunks/routes/route89.js | 9 - .../tests/subjects/preload-chunks/style.css | 3 - .../subjects/prerendering-hydration/index.js | 2 +- .../progressive-hydration-preact8/index.js | 19 - .../package.json | 8 - .../preact.config.js | 7 - .../prerender-urls.json | 15 - .../routes/home.js | 12 - packages/cli/tests/subjects/proxy/index.js | 1 - .../cli/tests/subjects/public-path/index.js | 1 - .../subjects/public-path/preact.config.js | 2 +- .../cli/tests/subjects/static-root/index.js | 2 - packages/cli/tests/watch.test.js | 21 +- packages/create-cli/README.md | 63 + packages/create-cli/package.json | 40 + packages/create-cli/src/commands/create.js | 145 + .../{cli => create-cli}/src/commands/list.js | 0 packages/create-cli/src/index.js | 41 + packages/create-cli/src/resources/sw.js | 4 + .../create-cli/src/resources/template.ejs | 27 + packages/create-cli/src/util.js | 50 + packages/create-cli/tests/.eslintrc | 9 + .../{cli => create-cli}/tests/create.test.js | 20 +- .../tests/images/create.js | 8 +- packages/prerender-data-provider/src/hook.js | 4 +- .../src/render-prop.js | 4 +- yarn.lock | 4109 ++++++----------- 129 files changed, 2970 insertions(+), 5081 deletions(-) create mode 100644 .changeset/cuddly-ducks-reply.md create mode 100644 .changeset/cyan-tomatoes-count.md create mode 100644 .changeset/great-dryers-cross.md create mode 100644 .changeset/hungry-peas-look.md create mode 100644 .changeset/lucky-lizards-drive.md create mode 100644 .changeset/metal-roses-flash.md create mode 100644 .changeset/poor-sloths-mate.md create mode 100644 .changeset/popular-zebras-yell.md create mode 100644 .changeset/quiet-eels-fix.md create mode 100644 .changeset/rude-walls-dress.md create mode 100644 .changeset/sweet-snakes-cheat.md create mode 100644 .changeset/tender-lamps-boil.md create mode 100644 .changeset/tiny-garlics-argue.md delete mode 100644 packages/async-loader/async-legacy.js delete mode 100644 packages/async-loader/legacy.js delete mode 100644 packages/cli/babel/index.js delete mode 100644 packages/cli/src/commands/create.js delete mode 100644 packages/cli/src/commands/index.js create mode 100644 packages/cli/src/commands/info.js delete mode 100644 packages/cli/src/constants.js delete mode 100644 packages/cli/src/lib/setup.js delete mode 100644 packages/cli/src/lib/webpack/create-load-manifest.js create mode 100644 packages/cli/src/lib/webpack/critters-plugin.js delete mode 100644 packages/cli/src/lib/webpack/push-manifest.js delete mode 100644 packages/cli/src/lib/webpack/utils.js delete mode 100644 packages/cli/src/resources/body-end.ejs delete mode 100644 packages/cli/src/resources/head-end.ejs delete mode 100644 packages/cli/src/resources/static-app.json create mode 100644 packages/cli/src/resources/template.ejs delete mode 100644 packages/cli/src/resources/template.html delete mode 100644 packages/cli/tests/subjects/css-auto-modules/components/index.js delete mode 100644 packages/cli/tests/subjects/css-auto-modules/components/style.css delete mode 100644 packages/cli/tests/subjects/css-auto-modules/index.js delete mode 100644 packages/cli/tests/subjects/css-auto-modules/routes/index.js delete mode 100644 packages/cli/tests/subjects/css-auto-modules/routes/style.css create mode 100644 packages/cli/tests/subjects/css-modules/index.js rename packages/cli/tests/subjects/{css-auto-modules => css-modules}/package.json (100%) rename packages/cli/tests/subjects/{css-auto-modules/global.css => css-modules/style.css} (100%) create mode 100644 packages/cli/tests/subjects/css-modules/style.module.css delete mode 100644 packages/cli/tests/subjects/css-sass/components/app/index.js delete mode 100644 packages/cli/tests/subjects/css-sass/components/app/style.scss create mode 100644 packages/cli/tests/subjects/css-sass/style.module.sass rename packages/cli/tests/subjects/{preload-chunks/routes/home.css => css-sass/style.module.scss} (71%) create mode 100644 packages/cli/tests/subjects/css-sass/style.sass create mode 100644 packages/cli/tests/subjects/css-sass/style.scss rename packages/cli/tests/subjects/custom-template/{template.html => template.ejs} (53%) delete mode 100644 packages/cli/tests/subjects/preload-chunks/index.js delete mode 100644 packages/cli/tests/subjects/preload-chunks/package.json delete mode 100644 packages/cli/tests/subjects/preload-chunks/routes/base.js delete mode 100644 packages/cli/tests/subjects/preload-chunks/routes/home.js delete mode 100644 packages/cli/tests/subjects/preload-chunks/routes/route66.css delete mode 100644 packages/cli/tests/subjects/preload-chunks/routes/route66.js delete mode 100644 packages/cli/tests/subjects/preload-chunks/routes/route89.css delete mode 100644 packages/cli/tests/subjects/preload-chunks/routes/route89.js delete mode 100644 packages/cli/tests/subjects/preload-chunks/style.css delete mode 100644 packages/cli/tests/subjects/progressive-hydration-preact8/index.js delete mode 100644 packages/cli/tests/subjects/progressive-hydration-preact8/package.json delete mode 100644 packages/cli/tests/subjects/progressive-hydration-preact8/preact.config.js delete mode 100644 packages/cli/tests/subjects/progressive-hydration-preact8/prerender-urls.json delete mode 100644 packages/cli/tests/subjects/progressive-hydration-preact8/routes/home.js create mode 100644 packages/create-cli/README.md create mode 100644 packages/create-cli/package.json create mode 100644 packages/create-cli/src/commands/create.js rename packages/{cli => create-cli}/src/commands/list.js (100%) create mode 100755 packages/create-cli/src/index.js create mode 100644 packages/create-cli/src/resources/sw.js create mode 100644 packages/create-cli/src/resources/template.ejs create mode 100644 packages/create-cli/src/util.js create mode 100644 packages/create-cli/tests/.eslintrc rename packages/{cli => create-cli}/tests/create.test.js (69%) rename packages/{cli => create-cli}/tests/images/create.js (86%) diff --git a/.changeset/cuddly-ducks-reply.md b/.changeset/cuddly-ducks-reply.md new file mode 100644 index 000000000..ff68b3d00 --- /dev/null +++ b/.changeset/cuddly-ducks-reply.md @@ -0,0 +1,6 @@ +--- +'@preact/async-loader': major +'preact-cli': major +--- + +Drops support for Preact v8 diff --git a/.changeset/cyan-tomatoes-count.md b/.changeset/cyan-tomatoes-count.md new file mode 100644 index 000000000..5a82bcac3 --- /dev/null +++ b/.changeset/cyan-tomatoes-count.md @@ -0,0 +1,11 @@ +--- +'preact-cli': major +--- + +Alters CSS Module detection to instead rely upon file names, rather than directory names. + +Treating all CSS files found within `routes/` and `components/` as CSS Modules was not obvious, nor did it offer an easy way to opt out (or in) without editing the Webpack config itself. + +This change makes is so that users can opt into CSS Modules from anywhere in their app by instead naming their CSS files according to the pattern `*.module.css`. + +Anyone using CSS Modules within `routes/` or `components/` will need to alter their CSS files to be `x.module.css`. If you've disabled CSS Modules in your `preact.config.js`, you can remove that bit of configuration and use file names to instead determine behavior. diff --git a/.changeset/great-dryers-cross.md b/.changeset/great-dryers-cross.md new file mode 100644 index 000000000..aeda7e193 --- /dev/null +++ b/.changeset/great-dryers-cross.md @@ -0,0 +1,9 @@ +--- +'preact-cli': major +--- + +Reduces the `env` parameter of `preact.config.js` to only contain 3 values: `isProd`, `isWatch`, and `isServer`. + +Previously, `env` contained many semi-duplicated values (`production` and `isProd`, etc) as well as values that were unlikely to be of much use to many users (what flags were set, for instance). Because of this, the signal-to-noise ratio was rather low which we didn't like. As such, we reduced `env` down to the most basic environment info: what type of build is `preact-cli` doing and for which environement? + +If you customize your Webpack config using a `preact.config.js`, please be aware that you may need to update which values you consume from `env`. diff --git a/.changeset/hungry-peas-look.md b/.changeset/hungry-peas-look.md new file mode 100644 index 000000000..6580e5585 --- /dev/null +++ b/.changeset/hungry-peas-look.md @@ -0,0 +1,9 @@ +--- +'preact-cli': major +--- + +To increase transparency and user control over the `template.html`, `<% preact.headEnd %>` and `<% preact.bodyEnd %>` will no longer be supported; instead, users should directly adopt the EJS and keep it in their templates. + +In the past, these were abstracted away as they were a bit unwieldy; EJS might be unfamiliar with users and the way data was retrieved from `html-webpack-plugin` was somewhat less than elegant. However, this has much improved over the years and the abstraction only makes simple edits less than obvious, so it is no longer fulfilling it's purpose. + +New projects will have a `template.ejs` created in place of the old `template.html`, containing the full EJS template. For existing projects, you can copy [the default `template.ejs`](https://github.com/preactjs/preact-cli/blob/master/packages/cli/src/resources/template.ejs) into your project or adapt it as you wish. diff --git a/.changeset/lucky-lizards-drive.md b/.changeset/lucky-lizards-drive.md new file mode 100644 index 000000000..331225065 --- /dev/null +++ b/.changeset/lucky-lizards-drive.md @@ -0,0 +1,5 @@ +--- +'preact-cli': major +--- + +HMR / the `--refresh` flag is now enabled by default in dev mode. diff --git a/.changeset/metal-roses-flash.md b/.changeset/metal-roses-flash.md new file mode 100644 index 000000000..109c218b0 --- /dev/null +++ b/.changeset/metal-roses-flash.md @@ -0,0 +1,7 @@ +--- +'preact-cli': major +--- + +Changes the JSX transform from 'classic' to the newer 'automatic' + +Users will no longer need to add `import { h } from 'preact'` in their components; it will be done automatically for them. diff --git a/.changeset/poor-sloths-mate.md b/.changeset/poor-sloths-mate.md new file mode 100644 index 000000000..e638a42be --- /dev/null +++ b/.changeset/poor-sloths-mate.md @@ -0,0 +1,5 @@ +--- +'preact-cli': major +--- + +Removes `--preload` flag and functionality from build command. diff --git a/.changeset/popular-zebras-yell.md b/.changeset/popular-zebras-yell.md new file mode 100644 index 000000000..a6d2df930 --- /dev/null +++ b/.changeset/popular-zebras-yell.md @@ -0,0 +1,5 @@ +--- +'preact-cli': patch +--- + +Disables hash in CSS file names for the SSR build diff --git a/.changeset/quiet-eels-fix.md b/.changeset/quiet-eels-fix.md new file mode 100644 index 000000000..335af1304 --- /dev/null +++ b/.changeset/quiet-eels-fix.md @@ -0,0 +1,5 @@ +--- +'preact-cli': major +--- + +Removes `--json` & `--brotli` flags from `preact build`. Also removes `--rhl` alias for `--refresh` from `preact watch`. diff --git a/.changeset/rude-walls-dress.md b/.changeset/rude-walls-dress.md new file mode 100644 index 000000000..d6d0f64fe --- /dev/null +++ b/.changeset/rude-walls-dress.md @@ -0,0 +1,6 @@ +--- +'preact-cli': major +'@preact/prerender-data-provider': major +--- + +Updates to use html-webpack-plugin v4 diff --git a/.changeset/sweet-snakes-cheat.md b/.changeset/sweet-snakes-cheat.md new file mode 100644 index 000000000..4f87f1b9e --- /dev/null +++ b/.changeset/sweet-snakes-cheat.md @@ -0,0 +1,12 @@ +--- +'preact-cli': major +--- + +- Upgrades to Webpack v5 + - Any custom configuration you do in your `preact.config.js` may need to be altered to account for this. Plugins may need replacements or different option formats. + +- `--esm` flag has been removed + - Dual output is now enabled by default in production builds. + +- `.babelrc` no longer overwrites matching keys + - Instead, the config will be merged in to the default. The default still takes precedence when there are conflicts, so you will still need to use your `preact.config.js` if you want to edit or remove default plugins or presets. diff --git a/.changeset/tender-lamps-boil.md b/.changeset/tender-lamps-boil.md new file mode 100644 index 000000000..4e33286c2 --- /dev/null +++ b/.changeset/tender-lamps-boil.md @@ -0,0 +1,9 @@ +--- +'preact-cli': major +--- + +Minimum supported Node version for `preact-cli` is now v14.14.0. Please upgrade if you are on an older version. + +`build` and `watch` commands will no longer take an optional `src` directory argument; if you want to change the source directory from the default (`./src`), please instead use the `--src` flag (i.e., `--src differentSrc`). + +Upon rebuild, the output directory will no longer be outright deleted; instead, it will be emptied. This has the benefit of better supporting containerized environments where specific directories are mounted. Emptying the directory, rather than deleting and recreating it, ensures a stable reference for those tools. diff --git a/.changeset/tiny-garlics-argue.md b/.changeset/tiny-garlics-argue.md new file mode 100644 index 000000000..4a11690db --- /dev/null +++ b/.changeset/tiny-garlics-argue.md @@ -0,0 +1,14 @@ +--- +'preact-cli': major +'create-preact-cli': major +--- + +Extracts project creation functionality from `preact-cli` into `create-preact-cli` + +Setting up new `preact-cli` projects with `npx` is slow, as all dependencies of `preact-cli` would need to be installed, even though only a handful are used for project initialization. On the other hand, suggesting global installs is less than attractive due to NPM's poor default install location (requires `sudo`) and this can get out of sync over time. + +By extracting project initialization into its own package, we can provide much, much faster project setup times. + +To setup a new project, users will use `npm init preact-cli ...` or `yarn create preact-cli ...`. + +Additionally, the `--yarn` flag has been removed in favour of using the yarn initializer (`yarn create`). diff --git a/.eslintignore b/.eslintignore index 66e817fc8..4ec2f1666 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,3 +1,4 @@ **/node_modules **/tests/output +**/tests/subjects/*/preact.config.js **/*.d.ts diff --git a/.eslintrc b/.eslintrc index 78212fde0..fbb76696d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,19 +1,12 @@ { - "extends": [ - "eslint:recommended", - "prettier" - ], + "extends": ["eslint:recommended", "prettier"], "parser": "babel-eslint", "env": { "browser": true, "node": true, "es6": true }, - "plugins": [ - "babel", - "react", - "prettier" - ], + "plugins": ["babel", "react", "prettier"], "settings": { "react": { "pragma": "h", @@ -29,6 +22,13 @@ "rules": { "no-console": 1, "no-empty": 0, + "no-unused-vars": [ + 2, + { + "argsIgnorePattern": "^_", + "varsIgnorePattern": "^_" + } + ], "semi": 2, "keyword-spacing": 2, "require-atomic-updates": 0, diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9b2da1e13..a7f3887a9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: timeout-minutes: 10 strategy: matrix: - node-version: [12.x, 14.x] + node-version: [14.x, 16.x] steps: - uses: actions/checkout@v2 diff --git a/README.md b/README.md index 91b5651c2..9d55da5e4 100644 --- a/README.md +++ b/README.md @@ -45,35 +45,29 @@ ### Requirements -> **Important**: [Node.js](https://nodejs.org/en/) >= v12 is required. +> **Important**: [Node.js](https://nodejs.org/en/) >= v14.14 is required. ### Usage ```sh -$ npx preact-cli create -``` +$ npm init preact-cli -> **Note** -> You can try out the v4 beta by using either of the following initializers instead (and they should be much faster!): -> ``` -> $ npm init preact-cli -> -> $ yarn create preact-cli -> ``` +$ yarn create preact-cli +``` Example: ```sh -$ npx preact-cli create default my-project +$ npm init preact-cli default my-project ``` -The above command pulls the template from [preactjs-templates/default], prompts for some information, and generates the project at `./my-project/`. +The above command pulls the template from [preactjs-templates/default] and generates the project at `./my-project/`. ### Official Templates The purpose of official preact project templates are to provide opinionated development tooling setups so that users can get started with actual app code as fast as possible. However, these templates are un-opinionated in terms of how you structure your app code and what libraries you use in addition to preact.js. -All official project templates are repos in the [preactjs-templates organization]. When a new template is added to the organization, you will be able to run `npx preact-cli create ` to use that template. +All official project templates are repos in the [preactjs-templates organization]. When a new template is added to the organization, you will be able to run `npm init preact-cli ` to use that template. Current available templates include: @@ -89,50 +83,50 @@ Current available templates include: - [widget-typescript] - Widget template implemented in TypeScript -> 💁 Tip: Any Github repo with a `'template'` folder can be used as a custom template:
`npx preact-cli create / ` +> 💁 Tip: Any Github repo with a `'template'` folder can be used as a custom template:
`npm init preact-cli / ` ### CLI Options +#### preact list + +Lists all the official preactjs-cli repositories + +```sh +$ [npm init / yarn create] preact-cli list +``` + #### preact create Create a project to quick start development. ``` -$ npx preact-cli create +$ [npm init / yarn create] preact-cli --name The application name. --cwd A directory to use instead of $PWD. --force Force option to create the directory for the new app [boolean] [default: false] - --yarn Installs dependencies with yarn. [boolean] [default: false] --git Initialize version control using git. [boolean] [default: false] --install Installs dependencies. [boolean] [default: true] ``` -Note: If you don't specify enough data to the `npx preact-cli create` command, it will prompt the required questions. - #### preact build Create a production build -You can disable `default: true` flags by prefixing them with `--no-