From 7f4be33861e37b50a2a5e7ebc5da1556ceae9cf4 Mon Sep 17 00:00:00 2001 From: Hans5958 Date: Sat, 18 Mar 2023 12:02:56 +0700 Subject: [PATCH] Merge both package.json, simplify build process --- tools/ci/.parcelrc => .parcelrc | 0 package.json | 36 +++++++++++++++++-- .../ci/postcss.config.js => postcss.config.js | 6 ++-- tools/ci/build-prod.sh | 5 --- tools/ci/package.json | 36 ------------------- 5 files changed, 36 insertions(+), 47 deletions(-) rename tools/ci/.parcelrc => .parcelrc (100%) rename tools/ci/postcss.config.js => postcss.config.js (76%) delete mode 100644 tools/ci/package.json diff --git a/tools/ci/.parcelrc b/.parcelrc similarity index 100% rename from tools/ci/.parcelrc rename to .parcelrc diff --git a/package.json b/package.json index 4fc43196..14e9d10c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,37 @@ { "devDependencies": { + "@fullhuman/postcss-purgecss": "^4.1.3", + "@parcel/packager-raw-url": "^2.5.0", + "@parcel/transformer-jsonld": "^2.5.0", + "@parcel/transformer-webmanifest": "^2.5.0", + "parcel": "^2.5.0", + "parcel-namer-rewrite": "^2.0.0-rc.2", + "parcel-resolver-ignore": "^2.1.3", + "postcss": "^8.4.12", "all-contributors-cli": "^6.23.1" - } -} + }, + "parcel-namer-rewrite": { + "rules": { + "^(icon-.+)\\.(svg|png|gif|jpg|jpeg)": "_img/pwa/$1.$2", + "^(screenshot-.+)\\.(svg|png|gif|jpg|jpeg)": "_img/pwa/$1.$2", + "(.*)\\.(svg|png|gif|jpg|jpeg)": "_img/$1.$2", + "(.*)\\.(css|woff2?)": "_css/$1{.hash}.$2", + "(.*)\\.(js)": "_js/$1{.hash}.$2" + } + }, + "parcelIgnore": [ + "pwabuilder-sw-register.js", + "pwabuilder-sw.js" + ], + "browserslist": [ + ">= 0.5%", + "last 2 major versions", + "not dead", + "Chrome >= 60", + "Firefox >= 60", + "Firefox ESR", + "iOS >= 12", + "Safari >= 12", + "not Explorer <= 11" + ] +} \ No newline at end of file diff --git a/tools/ci/postcss.config.js b/postcss.config.js similarity index 76% rename from tools/ci/postcss.config.js rename to postcss.config.js index d4319610..90244957 100644 --- a/tools/ci/postcss.config.js +++ b/postcss.config.js @@ -1,10 +1,8 @@ -const purgecss = require("@fullhuman/postcss-purgecss"); - const plugins = []; if (process.env.NODE_ENV === "production") { plugins.push( - purgecss({ + require("@fullhuman/postcss-purgecss")({ content: [ './dist-temp/*.html', './dist-temp/**/*.html', @@ -17,5 +15,5 @@ if (process.env.NODE_ENV === "production") { } module.exports = { - plugins: plugins + plugins }; \ No newline at end of file diff --git a/tools/ci/build-prod.sh b/tools/ci/build-prod.sh index 6e9abc63..cb72c362 100644 --- a/tools/ci/build-prod.sh +++ b/tools/ci/build-prod.sh @@ -6,17 +6,12 @@ rm -rf dist rm -rf .parcel-cache cp -r web/ dist-temp/ -cp tools/ci/postcss.config.js ./ -cp tools/ci/package.json ./ -cp tools/ci/.parcelrc ./ npm i python tools/ci/cdn-to-local.py npx parcel build dist-temp/index.html dist-temp/**.html --dist-dir "dist" --no-source-maps --no-content-hash rm -rf dist-temp -rm -rf postcss.config.js -rm -rf .parcelrc cp -r web/_img/ dist/ cp web/atlas.json dist/ diff --git a/tools/ci/package.json b/tools/ci/package.json deleted file mode 100644 index b0644b72..00000000 --- a/tools/ci/package.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "devDependencies": { - "@fullhuman/postcss-purgecss": "^4.1.3", - "@parcel/packager-raw-url": "^2.5.0", - "@parcel/transformer-jsonld": "^2.5.0", - "@parcel/transformer-webmanifest": "^2.5.0", - "parcel": "^2.5.0", - "parcel-namer-rewrite": "^2.0.0-rc.2", - "parcel-resolver-ignore": "^2.1.3", - "postcss": "^8.4.12" - }, - "parcel-namer-rewrite": { - "rules": { - "^(icon-.+)\\.(svg|png|gif|jpg|jpeg)": "_img/pwa/$1.$2", - "^(screenshot-.+)\\.(svg|png|gif|jpg|jpeg)": "_img/pwa/$1.$2", - "(.*)\\.(svg|png|gif|jpg|jpeg)": "_img/$1.$2", - "(.*)\\.(css|woff2?)": "_css/$1{.hash}.$2", - "(.*)\\.(js)": "_js/$1{.hash}.$2" - } - }, - "parcelIgnore": [ - "pwabuilder-sw-register.js", - "pwabuilder-sw.js" - ], - "browserslist": [ - ">= 0.5%", - "last 2 major versions", - "not dead", - "Chrome >= 60", - "Firefox >= 60", - "Firefox ESR", - "iOS >= 12", - "Safari >= 12", - "not Explorer <= 11" - ] -}