Skip to content

Commit

Permalink
feat: copy docs to the dist
Browse files Browse the repository at this point in the history
  • Loading branch information
isk committed Nov 14, 2023
1 parent 2559d89 commit 0b9c9a6
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 29 deletions.
7 changes: 3 additions & 4 deletions packages/demo/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
"private": true,
"version": "0.4.3",
"scripts": {
"prebuild": "./scripts/preBuild.sh",
"start": "pnpm run prebuild && webpack serve --config webpack.dev.js --mode development",
"build": "pnpm run prebuild && parcel build public/index.html",
"build:e2e": "pnpm run prebuild && pnpm run build",
"start": "webpack serve --config webpack.dev.js --mode development",
"build": "webpack --config webpack.prod.js --mode=production",
"build:e2e": "pnpm run build",
"dev": "pnpm run build",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"lint:fix": "pnpm run lint --fix",
Expand Down
16 changes: 0 additions & 16 deletions packages/demo/scripts/preBuild.sh

This file was deleted.

18 changes: 9 additions & 9 deletions packages/demo/webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const HtmlWebpackPlugin = require("html-webpack-plugin");

const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");

module.exports = {
Expand All @@ -9,14 +9,14 @@ module.exports = {
path: path.resolve(__dirname, "dist"),
},
plugins: [
// new CopyWebpackPlugin({
// patterns: [
// {
// from: `${__dirname}/src/components/**/docs/*.+(ts|md)`,
// to: path.resolve(__dirname, "./public/docs"),
// },
// ],
// }),
new CopyWebpackPlugin({
patterns: [
{
from: `${__dirname}/src/pages/**/docs/*.+(ts|md)`,
to: `./docs/[name][ext]`,
},
],
}),
new HtmlWebpackPlugin({
template: "./public/index.html",
}),
Expand Down
67 changes: 67 additions & 0 deletions packages/demo/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
const ImageMinimizerPlugin = require("image-minimizer-webpack-plugin");
const TerserPlugin = require("terser-webpack-plugin");
const { merge } = require("webpack-merge");

const common = require("./webpack.config");

module.exports = merge(common, {
mode: "production",
performance: {
hints: false,
maxEntrypointSize: 512000,
maxAssetSize: 512000,
},
optimization: {
minimize: true,
minimizer: [
new TerserPlugin({
terserOptions: {
compress: true,
},
extractComments: false,
}),
new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.svgoMinify,
options: {
encodeOptions: {
multipass: true,
plugins: [
{
name: "preset-default",
params: {
overrides: {
removeViewBox: false,
},
},
},
],
},
},
},
}),
new ImageMinimizerPlugin({
minimizer: {
implementation: ImageMinimizerPlugin.sharpMinify,
options: {
encodeOptions: {
jpeg: {
quality: 100,
},
webp: {
lossless: true,
},
avif: {
lossless: true,
},
// by default 100% quality
png: {},
// by default 100% quality
gif: {},
},
},
},
}),
],
},
});

0 comments on commit 0b9c9a6

Please sign in to comment.