You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Alters CSS Module detection to instead rely upon file names, rather than directory names.
6
+
7
+
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.
8
+
9
+
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`.
10
+
11
+
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.
Reduces the `env` parameter of `preact.config.js` to only contain 3 values: `isProd`, `isWatch`, and `isServer`.
6
+
7
+
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?
8
+
9
+
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`.
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.
6
+
7
+
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.
8
+
9
+
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.
- 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.
7
+
8
+
-`--esm` flag has been removed
9
+
- Dual output is now enabled by default in production builds.
10
+
11
+
-`.babelrc` no longer overwrites matching keys
12
+
- 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.
Minimum supported Node version for `preact-cli` is now v14.14.0. Please upgrade if you are on an older version.
6
+
7
+
`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`).
8
+
9
+
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.
Extracts project creation functionality from `preact-cli` into `create-preact-cli`
7
+
8
+
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.
9
+
10
+
By extracting project initialization into its own package, we can provide much, much faster project setup times.
11
+
12
+
To setup a new project, users will use `npm init preact-cli ...` or `yarn create preact-cli ...`.
13
+
14
+
Additionally, the `--yarn` flag has been removed in favour of using the yarn initializer (`yarn create`).
The above command pulls the template from [preactjs-templates/default], prompts for some information, and generates the project at `./my-project/`.
64
+
The above command pulls the template from [preactjs-templates/default] and generates the project at `./my-project/`.
71
65
72
66
### Official Templates
73
67
74
68
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.
75
69
76
-
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 <template-name> <project-name>` to use that template.
70
+
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 <template-name> <project-name>` to use that template.
77
71
78
72
Current available templates include:
79
73
@@ -89,50 +83,50 @@ Current available templates include:
89
83
90
84
-[widget-typescript] - Widget template implemented in TypeScript
91
85
92
-
> 💁 Tip: Any Github repo with a `'template'` folder can be used as a custom template: <br /> `npx preact-cli create <username>/<repository> <project-name>`
86
+
> 💁 Tip: Any Github repo with a `'template'` folder can be used as a custom template: <br /> `npm init preact-cli <username>/<repository> <project-name>`
-c, --config Path to custom CLI config (default preact.config.js)
164
156
-H, --host Set server hostname (default 0.0.0.0)
@@ -171,18 +163,14 @@ Note:
171
163
1. You can run dev server using `HTTPS` then you can use the following `HTTPS=true preact watch`
172
164
2. You can run the dev server on a different port using `PORT=8091 preact watch`
173
165
174
-
#### preact list
166
+
#### preact info
175
167
176
-
Lists all the official preactjs-cli repositories
168
+
Prints debugging information concerning the local environment.
177
169
178
170
```sh
179
-
$ preact list
171
+
$ [npm run / yarn] preact info
180
172
```
181
173
182
-
#### preact info
183
-
184
-
Prints debugging information concerning the local environment.
185
-
186
174
### Pre-rendering
187
175
188
176
Preact CLI in order to follow [PRPL] pattern renders initial route (`/`) into generated static `index.html` - this ensures that users get to see your page before any JavaScript is run, and thus providing users with slow devices or poor connection your website's content much faster.
@@ -200,29 +188,29 @@ To make customizing your configuration easier, preact-cli supports plugins. Visi
200
188
201
189
#### Browserslist
202
190
203
-
You may customize your list of supported browser versions by declaring a [`"browserslist"`] key within your `package.json`. Changing these values will modify your JavaScript (via [`@babel/preset-env`]) and your CSS (via [`autoprefixer`](https://github.com/postcss/autoprefixer)) output.
191
+
You may customize your list of supported browser versions by declaring a [`"browserslist"`] key within your `package.json`. Changing these values will modify your legacy JavaScript (via [`@babel/preset-env`]) and your CSS (via [`autoprefixer`](https://github.com/postcss/autoprefixer)) output.
204
192
205
193
By default, `preact-cli` emulates the following config:
1. You may create a [`.babelrc`] file in your project's root directory. Any settings you define here will overwrite matching config-keys within[Preact CLI preset]. For example, if you pass a `"plugins"` object, it will replace & reset all Babel plugins that Preact CLI defaults to.
207
+
1. You may create a [`.babelrc`] file in your project's root directory, or use the `--babelConfig` path to point at any valid [Babel config file]. Any settings you define here will be merged into the[Preact CLI preset]. For example, if you pass a `"plugins"` object containing different plugins from those already in use, they will simply be added on top of the existing config. If there are conflicts, you'll want to look into option 2, as the default will take precedence.
220
208
221
-
2. If you'd like to modify or add to the existing Babel config, you must use a `preact.config.js` file. Visit the [Webpack](#webpack) section for more info, or check out the [Customize Babel] example!
209
+
2. If you'd like to modify the existing Babel config you must use a `preact.config.js` file. Visit the [Webpack](#webpack) section for more info, or check out the [Customize Babel] example!
222
210
223
211
#### Webpack
224
212
225
-
To customize preact-cli create a `preact.config.js` or a `preact.config.json` file.
213
+
To customize Preact-CLI's Webpack config, create a `preact.config.js` or a `preact.config.json` file:
226
214
227
215
> `preact.config.js`
228
216
@@ -306,18 +294,15 @@ export default () => {
306
294
307
295
#### Template
308
296
309
-
A template is used to render your page by [EJS](https://ejs.co/).
310
-
You can uses the data of `prerenderUrls` which does not have `title`, using `htmlWebpackPlugin.options.CLI_DATA.preRenderData` in EJS.
311
-
312
-
The default one is visible [here](packages/cli/src/resources/template.html) and it's going to be enough for the majority of cases.
297
+
To customize the HTML document that your app uses, edit the `template.ejs` file in your app's source directory.
313
298
314
-
If you want to customise your template you can pass a custom template with the `--template` flag.
299
+
[EJS](https://ejs.dev) is a simple templating language that lets you generate HTML markup with plain JavaScript. Alongside `html-webpack-plugin`, you're able to conditionally add HTML, access your bundles and assets, and link to external content if you wish. The default we provide on project initialization should fit the majority of use cases very well, but feel free to customize!
315
300
316
-
The `--template` flag is available on the `build` and `watch` commands.
301
+
You can customize the location of your template with the `--template` flag on the `build` and `watch` commands:
317
302
318
303
```sh
319
-
preact build --template src/template.html
320
-
preact watch --template src/template.html
304
+
preact build --template renamed-src/template.ejs
305
+
preact watch --template template.ejs
321
306
```
322
307
323
308
### Using CSS preprocessors
@@ -410,9 +395,9 @@ Automatic code splitting is applied to all JavaScript and TypeScript files in th
0 commit comments