Skip to content

Commit 67ab438

Browse files
committed
refactor: Remove --preload flag (#1737)
* refactor: Removes `--preload` flag & functionality * docs: Adding changeset * docs: Updating readme for removal of preload
1 parent eb49c2b commit 67ab438

File tree

23 files changed

+28
-410
lines changed

23 files changed

+28
-410
lines changed

.changeset/poor-sloths-mate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'preact-cli': major
3+
---
4+
5+
Removes `--preload` flag and functionality from build command.

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,6 @@ $ [npm run / yarn] preact build
133133
--babelConfig Path to custom Babel config (default .babelrc)
134134
--json Generate build stats for bundle analysis
135135
--template Path to custom HTML template (default 'src/template.html')
136-
--preload Adds preload tags to the document its assets (default false)
137136
--analyze Launch interactive Analyzer to inspect production bundle(s)
138137
--prerender Renders route(s) into generated static HTML (default true)
139138
--prerenderUrls Path to pre-rendered routes config (default prerender-urls.json)

packages/cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
"webpack": "^5.67.0",
8686
"webpack-bundle-analyzer": "^4.5.0",
8787
"webpack-dev-server": "^4.9.0",
88-
"webpack-manifest-plugin": "^5.0.0",
8988
"webpack-merge": "^5.8.0",
9089
"webpack-remove-empty-scripts": "^0.7.2",
9190
"workbox-cacheable-response": "^6.5.3",

packages/cli/src/index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ prog
4040
'--template',
4141
'Path to custom HTML template (default "src/template.html")'
4242
)
43-
.option(
44-
'--preload',
45-
'Adds preload links to the HTML for required resources',
46-
false
47-
)
4843
.option(
4944
'--analyze',
5045
'Launch interactive Analyzer to inspect production bundle(s)',

packages/cli/src/lib/webpack/create-load-manifest.js

Lines changed: 0 additions & 69 deletions
This file was deleted.

packages/cli/src/lib/webpack/push-manifest.js

Lines changed: 0 additions & 32 deletions
This file was deleted.

packages/cli/src/lib/webpack/render-html-plugin.js

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ const {
77
} = require('html-webpack-skip-assets-plugin');
88
const HtmlWebpackPlugin = require('html-webpack-plugin');
99
const prerender = require('./prerender');
10-
const createLoadManifest = require('./create-load-manifest');
1110
const { error, esmImport, tryResolveConfig, warn } = require('../../util');
1211

1312
const PREACT_FALLBACK_URL = '/200.html';
@@ -79,26 +78,16 @@ module.exports = async function renderHTMLPlugin(config) {
7978
entryFiles.find(file => /\.(m?js)(\?|$)/.test(file));
8079
});
8180

82-
let loadManifest = compilation.assets['push-manifest.json']
83-
? JSON.parse(compilation.assets['push-manifest.json'].source())
84-
: createLoadManifest(
85-
compilation.assets,
86-
compilation.namedChunkGroups,
87-
config.isProd
88-
);
89-
9081
return {
9182
cli: {
9283
title,
9384
url,
9485
manifest: config.manifest,
9586
inlineCss: config['inline-css'],
96-
preload: config.preload,
9787
config,
9888
prerenderData: values,
9989
CLI_DATA: { prerenderData: { url, ...routeData } },
10090
ssr: config.prerender ? prerender({ cwd, dest, src }, values) : '',
101-
loadManifest,
10291
entrypoints,
10392
},
10493
htmlWebpackPlugin: {

packages/cli/src/lib/webpack/webpack-base-config.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const ProgressBarPlugin = require('progress-bar-webpack-plugin');
1010
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
1111
const createBabelConfig = require('../babel-config');
1212
const loadPostcssConfig = require('postcss-load-config');
13-
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
1413

1514
function readJson(file) {
1615
try {
@@ -298,15 +297,6 @@ module.exports = function createBaseConfig(env) {
298297
summary: false,
299298
clear: true,
300299
}),
301-
new WebpackManifestPlugin({
302-
fileName: 'asset-manifest.json',
303-
assetHookStage: webpack.Compiler.PROCESS_ASSETS_STAGE_ANALYSE,
304-
// TODO: Remove this next breaking change and use the full filepath from this manifest
305-
// when referring to built assets, i.e.:
306-
// https://github.com/preactjs/preact-cli/blob/master/packages/cli/src/resources/head-end.ejs#L1
307-
// This is just to avoid any potentially breaking changes for right now.
308-
publicPath: '',
309-
}),
310300
tsconfig &&
311301
new ForkTsCheckerWebpackPlugin({
312302
typescript: {

packages/cli/src/lib/webpack/webpack-client-config.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const CssMinimizerPlugin = require('css-minimizer-webpack-plugin');
1010
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
1111
const CrittersPlugin = require('critters-webpack-plugin');
1212
const renderHTMLPlugin = require('./render-html-plugin');
13-
const PushManifestPlugin = require('./push-manifest');
1413
const baseConfig = require('./webpack-base-config');
1514
const { InjectManifest } = require('workbox-webpack-plugin');
1615
const CompressionPlugin = require('compression-webpack-plugin');
@@ -123,7 +122,6 @@ async function clientConfig(env) {
123122
'process.env.ADD_SW': env.sw,
124123
'process.env.PRERENDER': env.prerender,
125124
}),
126-
new PushManifestPlugin(env.isProd),
127125
...(await renderHTMLPlugin(env)),
128126
copyPatterns.length !== 0 &&
129127
new CopyWebpackPlugin({

packages/cli/src/resources/head-end.ejs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,3 @@
22
<% if (cli.manifest.theme_color) { %>
33
<meta name="theme-color" content="<%= cli.manifest.theme_color %>">
44
<% } %>
5-
<% const filesRegexp = cli.inlineCss ? /\.(chunk\.\w{5}\.css|js)$/ : /\.(css|js)$/;%>
6-
<% for (const file in cli.loadManifest[cli.url]) { %>
7-
<% if (cli.preload && file && file.match(filesRegexp)) { %>
8-
<% /* crossorigin for main bundle as that is loaded from `<script type=module` tag, other lazy loaded bundles are from webpack so its not needed */ %>
9-
<link rel="preload" href="<%= htmlWebpackPlugin.files.publicPath + file %>" as="<%= file.match(/\.css$/)?'style':'script' %>" <%= file.match(/bundle\.\w{5}\.(?<!legacy)\.js$/)?'crossorigin="anonymous"':'' %>>
10-
<% } %>
11-
<% } %>

0 commit comments

Comments
 (0)