From 19382640c7c9dbf0b80fa8dbcdd7f3016af5de39 Mon Sep 17 00:00:00 2001 From: osdevisnot Date: Mon, 9 Apr 2018 13:43:00 -0700 Subject: [PATCH 01/10] closes #527 add lighthouse badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a2ab02d1..37d2e5f11 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# preact-cli [![Build Status](https://travis-ci.org/developit/preact-cli.svg?branch=master)](https://travis-ci.org/developit/preact-cli) [![NPM Downloads](https://img.shields.io/npm/dm/preact-cli.svg?style=flat)](https://www.npmjs.com/package/preact-cli) [![NPM Version](https://img.shields.io/npm/v/preact-cli.svg?style=flat)](https://www.npmjs.com/package/preact-cli) +# preact-cli [![Build Status](https://travis-ci.org/developit/preact-cli.svg?branch=master)](https://travis-ci.org/developit/preact-cli) [![NPM Downloads](https://img.shields.io/npm/dm/preact-cli.svg?style=flat)](https://www.npmjs.com/package/preact-cli) [![NPM Version](https://img.shields.io/npm/v/preact-cli.svg?style=flat)](https://www.npmjs.com/package/preact-cli) [![Lighthouse score: 100/100](https://lighthouse-badge.appspot.com/?score=100)](https://github.com/developit/preact-cli) > Start building a [Preact] Progressive Web App in seconds 🔥 From 4448cff92679567efe383e399c549d3e71c83e48 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Fri, 27 Jul 2018 11:09:41 -0400 Subject: [PATCH 02/10] Add a static .prefetch() method to async! wrapper import Foo from 'async!./foo' Foo.prefetch() // we know we'll want it. render() --- src/components/async.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/async.js b/src/components/async.js index ac05422f8..ffb2ccede 100644 --- a/src/components/async.js +++ b/src/components/async.js @@ -25,5 +25,6 @@ export default function(req) { this.render = (p, s) => s.child ? h(s.child, p) : old; } (Async.prototype = new Component).constructor = Async; + Async.prefetch = req; return Async; } From 7ed39aae144b443d8a7c6edd5bfd35ea65535c71 Mon Sep 17 00:00:00 2001 From: DanielApt Date: Mon, 6 Aug 2018 14:28:02 +0100 Subject: [PATCH 03/10] Fix typo in `npm run serve --server` (#602) Unneeded `-- ` characters --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 37d2e5f11..feca0f6c9 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ $ preact list npm run build # generate configuration in Firebase Hosting format: -npm run serve -- --server config +npm run serve --server config # Copy your static files to a server! ``` From f936a3b89a88fc8bcd2098ff29bbb06d46adad85 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Mon, 6 Aug 2018 14:09:17 -0400 Subject: [PATCH 04/10] Revert #602 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index feca0f6c9..37d2e5f11 100644 --- a/README.md +++ b/README.md @@ -146,7 +146,7 @@ $ preact list npm run build # generate configuration in Firebase Hosting format: -npm run serve --server config +npm run serve -- --server config # Copy your static files to a server! ``` From e621965b8a87e6fbf91149cadfe7e29caf09ee62 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Mon, 27 Aug 2018 16:41:25 -0400 Subject: [PATCH 05/10] Add PRERENDER env var (#625) * Add env.ssr * Define PRERENDER env var. --- src/lib/webpack/webpack-base-config.js | 3 ++- src/lib/webpack/webpack-server-config.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/lib/webpack/webpack-base-config.js b/src/lib/webpack/webpack-base-config.js index 4857f4b26..fdd03c8dd 100644 --- a/src/lib/webpack/webpack-base-config.js +++ b/src/lib/webpack/webpack-base-config.js @@ -204,7 +204,8 @@ export default function (env) { plugins: [ new webpack.NoEmitOnErrorsPlugin(), new webpack.DefinePlugin({ - 'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development') + 'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development'), + 'PRERENDER': env.ssr ? 'true' : 'false' }), // Extract CSS new ExtractTextPlugin({ diff --git a/src/lib/webpack/webpack-server-config.js b/src/lib/webpack/webpack-server-config.js index 948a83298..e3a3cf22e 100644 --- a/src/lib/webpack/webpack-server-config.js +++ b/src/lib/webpack/webpack-server-config.js @@ -24,6 +24,7 @@ function serverConfig(env) { } export default function (env) { + env = Object.assign({}, env, { ssr: true }); return merge( baseConfig(env), serverConfig(env) From ddc0bc81a7ad79b48ca818d7c6d0ba7b210c69c7 Mon Sep 17 00:00:00 2001 From: Cohan Carpentier <42348766+nahoc-petal@users.noreply.github.com> Date: Tue, 11 Sep 2018 15:38:24 -0400 Subject: [PATCH 06/10] Update README.md Added yarn command line. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 37d2e5f11..14d05c40c 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,10 @@ ```sh $ npm install -g preact-cli ``` +or +```sh +$ yarn global add preact-cli +``` ### Usage From e8e83a91561e21770aba88abfc64fb3fd1ff9654 Mon Sep 17 00:00:00 2001 From: Luke Edwards Date: Wed, 3 Oct 2018 15:55:53 -0700 Subject: [PATCH 07/10] Allow non-production builds (#653) * fix: `--production false` === `--no-production` * tie CSS extraction to `isWatch` bool --- src/commands/build.js | 5 +++++ src/lib/webpack/run-webpack.js | 1 + src/lib/webpack/webpack-base-config.js | 6 +++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/commands/build.js b/src/commands/build.js index ff10ae0d8..9a305b7c9 100644 --- a/src/commands/build.js +++ b/src/commands/build.js @@ -4,6 +4,8 @@ import { isDir, error } from '../util'; import asyncCommand from '../lib/async-command'; import runWebpack, { showStats, writeJsonStats } from '../lib/webpack/run-webpack'; +const toBool = val => val === void 0 || (val === 'false' ? false : val); + export default asyncCommand({ command: 'build [src] [dest]', @@ -60,6 +62,9 @@ export default asyncCommand({ let cwd = resolve(argv.cwd); let modules = resolve(cwd, 'node_modules'); + argv.prerender = toBool(argv.prerender); + argv.production = toBool(argv.production); + if (!isDir(modules)) { return error('No `node_modules` found! Please run `npm install` before continuing.', 1); } diff --git a/src/lib/webpack/run-webpack.js b/src/lib/webpack/run-webpack.js index c5bf31533..a6b21fd9e 100644 --- a/src/lib/webpack/run-webpack.js +++ b/src/lib/webpack/run-webpack.js @@ -13,6 +13,7 @@ import { error, isDir, warn } from '../../util'; export default function (watch=false, env, onprogress) { env.isProd = env.production; // shorthand + env.isWatch = !!watch; // use HMR? env.cwd = resolve(env.cwd || process.cwd()); // env.src='src' via `build` default diff --git a/src/lib/webpack/webpack-base-config.js b/src/lib/webpack/webpack-base-config.js index fdd03c8dd..e2d47d187 100644 --- a/src/lib/webpack/webpack-base-config.js +++ b/src/lib/webpack/webpack-base-config.js @@ -25,7 +25,7 @@ function resolveDep(dep, cwd) { } export default function (env) { - const { cwd, isProd, src, source } = env; + const { cwd, isProd, isWatch, src, source } = env; // Apply base-level `env` values env.dest = resolve(cwd, env.dest || 'build'); @@ -210,7 +210,7 @@ export default function (env) { // Extract CSS new ExtractTextPlugin({ filename: isProd ? 'style.[contenthash:5].css' : 'style.css', - disable: !isProd, + disable: isWatch, allChunks: true }), new webpack.optimize.CommonsChunkPlugin({ @@ -239,7 +239,7 @@ export default function (env) { }) ] : []), - devtool: isProd ? 'source-map' : 'cheap-module-eval-source-map', + devtool: isWatch ? 'cheap-module-eval-source-map' : 'source-map', node: { console: false, From 7e728a6ece225b31c7aad50be6e40b8f9c190106 Mon Sep 17 00:00:00 2001 From: Robbert Wethmar Date: Sun, 23 Dec 2018 13:46:27 +0100 Subject: [PATCH 08/10] fix create test after updates in default template --- tests/images/create.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/images/create.js b/tests/images/create.js index 2652a5e08..9ecd97c0c 100644 --- a/tests/images/create.js +++ b/tests/images/create.js @@ -1,8 +1,8 @@ exports.default = [ + '.babelrc', '.gitignore', 'package.json', 'README.md', - 'src/.babelrc', 'src/assets/favicon.ico', 'src/assets/icons/android-chrome-192x192.png', 'src/assets/icons/android-chrome-512x512.png', @@ -20,9 +20,9 @@ exports.default = [ 'src/routes/profile/index.js', 'src/routes/profile/style.css', 'src/style/index.css', - 'src/tests/__mocks__/browserMocks.js', - 'src/tests/__mocks__/fileMocks.js', - 'src/tests/header.test.js' + 'tests/__mocks__/browserMocks.js', + 'tests/__mocks__/fileMocks.js', + 'tests/header.test.js' ]; exports.full = exports.default; From 1945bc6338a68b23b04255e6bd136df66187f6e2 Mon Sep 17 00:00:00 2001 From: Jason Miller Date: Tue, 8 Jan 2019 15:21:37 -0500 Subject: [PATCH 09/10] [SW] Don't invoke skipWaiting This fixes the issue where lazy-loaded splitted chunks fail because the SW has been updated and the previous URLs are now 404's. --- src/lib/webpack/webpack-client-config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/lib/webpack/webpack-client-config.js b/src/lib/webpack/webpack-client-config.js index 9ebc91e11..8e3e9e158 100644 --- a/src/lib/webpack/webpack-client-config.js +++ b/src/lib/webpack/webpack-client-config.js @@ -152,6 +152,7 @@ function isProd(config) { navigateFallback: 'index.html', navigateFallbackWhitelist: [/^(?!\/__).*/], minify: true, + skipWaiting: false, stripPrefix: config.cwd, staticFileGlobsIgnorePatterns: [ /polyfills(\..*)?\.js$/, From e43f2714a9cdc4ade71342ac1db7e6efc86c2e27 Mon Sep 17 00:00:00 2001 From: Steve Anderson Date: Mon, 21 Jan 2019 12:46:16 +0000 Subject: [PATCH 10/10] Add missing options to `preact watch` The README currently doesn't include the documentation for `--template` and `--config` options for `preact watch`... so here they are. --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 37d2e5f11..c1e2e7403 100644 --- a/README.md +++ b/README.md @@ -105,9 +105,11 @@ $ preact watch --cwd A directory to use instead of $PWD. [string] [default: .] --src Entry file (index.js) [string] [default: "src"] --port, -p Port to start a server on [string] [default: "8080"] - --host, Hostname to start a server on [string] [default: "0.0.0.0"] + --host, -H Hostname to start a server on [string] [default: "0.0.0.0"] --https Use HTTPS? [boolean] [default: false] --prerender Pre-render static app content on initial build [boolean] [default: false] + --template Path to template used by webpack [string] [default: none] + --config, c Path to custom preact.config.js [string] [default: none] ``` Note: