1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-06-21 15:04:01 +02:00

upgrade to preact-cli 4

This commit is contained in:
Kushagra Gour
2024-02-28 09:36:04 +05:30
parent de56ee3e1f
commit 7bf0266f12
4 changed files with 5906 additions and 15092 deletions

20939
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -4,8 +4,8 @@
"description": "A blazing fast & offline web playground", "description": "A blazing fast & offline web playground",
"scripts": { "scripts": {
"start": "concurrently --kill-others \"gulp start-preview-server\" \"npm run -s dev\"", "start": "concurrently --kill-others \"gulp start-preview-server\" \"npm run -s dev\"",
"build": "preact build --template src/index.html --prerender false --no-inline-css --sw false --esm false", "build": "preact build --template src/index.ejs --prerender false --no-inline-css --sw false --esm false",
"dev": "preact watch --template src/index.html", "dev": "preact watch --template src/index.ejs",
"serve-website": "cd packages/website; npm start", "serve-website": "cd packages/website; npm start",
"build-website": "cd packages/website; npm run build", "build-website": "cd packages/website; npm run build",
"lint": "eslint src", "lint": "eslint src",
@ -65,7 +65,7 @@
"markdown-it": "^8.4.2", "markdown-it": "^8.4.2",
"markdown-it-anchor": "^5.0.2", "markdown-it-anchor": "^5.0.2",
"merge-stream": "^1.0.1", "merge-stream": "^1.0.1",
"preact-cli": "^3.0.0", "preact-cli": "^4.0.0-next.6",
"sw-precache": "^5.2.0" "sw-precache": "^5.2.0"
}, },
"dependencies": { "dependencies": {

View File

@ -1,5 +1,3 @@
// var CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin');
/** /**
* Function that mutates original webpack config. * Function that mutates original webpack config.
* Supports asynchronous changes when promise is returned. * Supports asynchronous changes when promise is returned.
@ -21,9 +19,9 @@ export default function (config, env, helpers) {
htmlWebpackPlugin.plugin.options.favicon = false; htmlWebpackPlugin.plugin.options.favicon = false;
// Required for lingui-macros // Required for lingui-macros
let { rule } = helpers.getLoadersByName(config, 'babel-loader')[0]; // let { rule } = helpers.getLoadersByName(config, 'babel-loader')[0];
let babelConfig = rule.options; // let babelConfig = rule.options;
babelConfig.plugins.push('macros'); // babelConfig.plugins.push('macros');
if (env.isProd) { if (env.isProd) {
config.devtool = false; // disable sourcemaps config.devtool = false; // disable sourcemaps
@ -33,25 +31,5 @@ export default function (config, env, helpers) {
// Remove the default hash append in chunk name // Remove the default hash append in chunk name
config.output.chunkFilename = '[name].chunk.js'; config.output.chunkFilename = '[name].chunk.js';
// config.plugins.push(
// new CommonsChunkPlugin({
// name: 'vendor',
// minChunks: ({ resource }) => /node_modules/.test(resource)
// })
// );
const swPlugin = helpers.getPluginsByName(
config,
'SWPrecacheWebpackPlugin'
)[0];
if (swPlugin) {
// config.plugins.splice(swPlugin.index, 1);
}
const uglifyPlugin = helpers.getPluginsByName(config, 'UglifyJsPlugin')[0];
if (uglifyPlugin) {
// config.plugins.splice(uglifyPlugin.index, 1);
}
} }
} }

View File

@ -11,11 +11,9 @@
rel="manifest" rel="manifest"
href="<%= htmlWebpackPlugin.files.publicPath %>manifest.json" href="<%= htmlWebpackPlugin.files.publicPath %>manifest.json"
/> />
<% if (htmlWebpackPlugin.options.manifest.theme_color) { %>
<meta <% if (cli.manifest.theme_color) { %>
name="theme-color" <meta name="theme-color" content="<%= cli.manifest.theme_color %>">
content="<%= htmlWebpackPlugin.options.manifest.theme_color %>"
/>
<% } %> <% } %>
<style> <style>
@ -73,13 +71,14 @@
<body> <body>
<div id="root"></div> <div id="root"></div>
<div id="portal"></div> <div id="portal"></div>
<!-- SCRIPT-TAGS -->
<%= htmlWebpackPlugin.options.ssr({ url: '/' }) %> <%= cli.ssr %>
<script <% if (cli.config.prerender === true) { %>
defer <script type="__PREACT_CLI_DATA__">
src="<%= htmlWebpackPlugin.files.chunks['bundle'].entry %>" <%= encodeURI(JSON.stringify(cli.CLI_DATA)) %>
></script> </script>
<% } %>
<!-- END-SCRIPT-TAGS --> <script type="module" src="<%= cli.entrypoints['bundle'] %>"></script>
<script nomodule src="<%= cli.entrypoints['dom-polyfills'] %>"></script>
</body> </body>
</html> </html>