Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: preactjs/preact-cli
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 56b318109456206d4159969c5bdc4224cc381e65
Choose a base ref
..
head repository: preactjs/preact-cli
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c1c12e3e71a75b09caccc66b5f947093d104fed6
Choose a head ref
5 changes: 5 additions & 0 deletions .changeset/popular-zebras-yell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'preact-cli': patch
---

Disables hash in CSS file names for the SSR build
1 change: 0 additions & 1 deletion packages/cli/lib/index.js
Original file line number Diff line number Diff line change
@@ -60,7 +60,6 @@ prog
Browsers: ['Chrome', 'Edge', 'Firefox', 'Safari'],
npmPackages: [
'preact',
'preact-compat',
'preact-cli',
'preact-router',
'preact-render-to-string',
6 changes: 4 additions & 2 deletions packages/cli/lib/lib/webpack/run-webpack.js
Original file line number Diff line number Diff line change
@@ -52,12 +52,14 @@ async function devBuild(env) {
}

async function prodBuild(env) {
env = { ...env, isServer: false, dev: !env.production, ssr: false };
let config = await clientConfig(env);
await transformConfig(env, config);

if (env.prerender) {
let ssrConfig = serverConfig(env);
await transformConfig(env, ssrConfig, true);
const serverEnv = Object.assign({}, env, { isServer: true, ssr: true });
let ssrConfig = serverConfig(serverEnv);
await transformConfig(serverEnv, ssrConfig);
let serverCompiler = webpack(ssrConfig);
await runCompiler(serverCompiler);
}
13 changes: 2 additions & 11 deletions packages/cli/lib/lib/webpack/transform-config.js
Original file line number Diff line number Diff line change
@@ -90,7 +90,7 @@ function parseConfig(config) {
return transformers;
}

module.exports = async function (env, webpackConfig, isServer = false) {
module.exports = async function (env, webpackConfig) {
const { configFile, isDefault } =
env.config !== 'preact.config.js'
? { configFile: env.config, isDefault: false }
@@ -122,16 +122,7 @@ module.exports = async function (env, webpackConfig, isServer = false) {
const helpers = new WebpackConfigHelpers(env.cwd);
for (let [transformer, options] of transformers) {
try {
await transformer(
webpackConfig,
Object.assign({}, env, {
isServer,
dev: !env.production,
ssr: isServer,
}),
helpers,
options
);
await transformer(webpackConfig, env, helpers, options);
} catch (err) {
throw new Error((`Error at ${cliConfig}: \n` + err && err.stack) || err);
}
24 changes: 6 additions & 18 deletions packages/cli/lib/lib/webpack/webpack-base-config.js
Original file line number Diff line number Diff line change
@@ -80,19 +80,6 @@ module.exports = function createBaseConfig(env) {
let cliNodeModules = findAllNodeModules(__dirname);
let nodeModules = [...new Set([...userNodeModules, ...cliNodeModules])];

let compat = 'preact-compat';
try {
compat = dirname(
require.resolve('preact/compat/package.json', { paths: [cwd] })
);
} catch (e) {
try {
compat = dirname(
require.resolve('preact-compat/package.json', { paths: [cwd] })
);
} catch (e) {}
}

let tsconfig = resolveTsconfig(cwd, isProd);

let postcssPlugins;
@@ -135,10 +122,10 @@ module.exports = function createBaseConfig(env) {
style: source('style'),
'preact-cli-entrypoint': source('index'),
url: dirname(require.resolve('native-url/package.json')),
// preact/compat aliases for supporting React dependencies:
react: compat,
'react-dom': compat,
'preact-compat': compat,
react: require.resolve('preact/compat'),
'react-dom/test-utils': require.resolve('preact/test-utils'),
'react-dom': require.resolve('preact/compat'),
'react/jsx-runtime': require.resolve('preact/jsx-runtime'),
'react-addons-css-transition-group': 'preact-css-transition-group',
'preact-cli/async-component': require.resolve(
'@preact/async-loader/async'
@@ -303,7 +290,8 @@ module.exports = function createBaseConfig(env) {
// Fix for https://github.com/webpack-contrib/mini-css-extract-plugin/issues/151
new RemoveEmptyScriptsPlugin(),
new MiniCssExtractPlugin({
filename: isProd ? '[name].[contenthash:5].css' : '[name].css',
filename:
isProd && !env.isServer ? '[name].[contenthash:5].css' : '[name].css',
chunkFilename: pathData => {
const chunkName = pathData.chunk.id.split('_').slice(0, -1).join('-');
return isProd
1 change: 0 additions & 1 deletion packages/cli/lib/lib/webpack/webpack-server-config.js
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ function serverConfig(env) {
publicPath: '/',
filename: 'ssr-bundle.js',
path: resolve(env.dest, 'ssr-build'),
chunkFilename: '[name].chunk.[chunkhash:5].js',
libraryTarget: 'commonjs2',
},
externals: {
34 changes: 17 additions & 17 deletions packages/cli/tests/images/build.js
Original file line number Diff line number Diff line change
@@ -7,18 +7,18 @@ exports.default = {
'assets/icons/mstile-150x150.png': 9050,
'assets/favicon.ico': 15086,

'ssr-build/ssr-bundle.c9123.css': 1281,
'ssr-build/ssr-bundle.c9123.css.map': 2070,
'ssr-build/ssr-bundle.css': 1281,
'ssr-build/ssr-bundle.css.map': 2070,
'ssr-build/ssr-bundle.js': 9801,
'ssr-build/ssr-bundle.js.map': 30625,
'ssr-build/asset-manifest.json': 82,
'ssr-build/asset-manifest.json': 76,

'bundle.3c823.js': 21323,
'bundle.3c823.js.map': 85534,
'bundle.3c823.legacy.js': 22514,
'bundle.3c823.legacy.js.map': 106422,
'bundle.a2557.css': 945,
'bundle.a2557.css.map': 1758,
'bundle.620ee.js': 21323,
'bundle.620ee.js.map': 85534,
'bundle.620ee.legacy.js': 22514,
'bundle.620ee.legacy.js.map': 106422,
'bundle.354c3.css': 945,
'bundle.354c3.css.map': 1758,

'dom-polyfills.c88f4.legacy.js': 5252,
'dom-polyfills.c88f4.legacy.js.map': 18836,
@@ -31,17 +31,17 @@ exports.default = {
'push-manifest.json': 450,
'asset-manifest.json': 943,

'route-home.chunk.a00bd.js': 339,
'route-home.chunk.a00bd.js.map': 1811,
'route-home.chunk.a00bd.legacy.js': 394,
'route-home.chunk.a00bd.legacy.js.map': 2102,
'route-home.chunk.4ad71.js': 339,
'route-home.chunk.4ad71.js.map': 1811,
'route-home.chunk.4ad71.legacy.js': 394,
'route-home.chunk.4ad71.legacy.js.map': 2102,
'route-home.chunk.6eaee.css': 112,
'route-home.chunk.6eaee.css.map': 224,

'route-profile.chunk.05dd0.js': 2545,
'route-profile.chunk.05dd0.js.map': 10268,
'route-profile.chunk.05dd0.legacy.js': 2698,
'route-profile.chunk.05dd0.legacy.js.map': 12894,
'route-profile.chunk.6a61d.js': 2545,
'route-profile.chunk.6a61d.js.map': 10268,
'route-profile.chunk.6a61d.legacy.js': 2698,
'route-profile.chunk.6a61d.legacy.js.map': 12894,
'route-profile.chunk.0af3e.css': 118,
'route-profile.chunk.0af3e.css.map': 231,
};
1 change: 0 additions & 1 deletion packages/create-cli/tests/images/create.js
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ exports.default = [
'src/assets/icons/favicon-16x16.png',
'src/assets/icons/favicon-32x32.png',
'src/assets/icons/mstile-150x150.png',
'src/components/app.js',
'src/components/header/index.js',
'src/components/header/style.module.css',
'src/index.js',