From 875113448b1a84b65bf333fbc050b1edd8e2a8cc Mon Sep 17 00:00:00 2001 From: Spedon <70063177+Sped0n@users.noreply.github.com> Date: Thu, 22 Feb 2024 23:44:16 +0800 Subject: [PATCH] refactor: migrate part of the sass compilation to vite (#283) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * refactor: migrate part of the sass compilation to vite now `bundled` option is deprecated * fix: update build script * chore: add a “type” field to the package.json file to resolve Vite’s complaints about CommonJS modules. --- assets/ts/main.tsx | 2 + exampleSite/config/_default/params.toml | 4 -- layouts/partials/head/link.html | 12 +--- package.json | 4 +- pnpm-lock.yaml | 73 +++++++++++++++++++++++-- static/bundled/css/main.css | 1 + static/bundled/css/style.min.css | 1 - vite.config.ts | 10 ++-- 8 files changed, 82 insertions(+), 25 deletions(-) create mode 100644 static/bundled/css/main.css delete mode 100644 static/bundled/css/style.min.css diff --git a/assets/ts/main.tsx b/assets/ts/main.tsx index 4dd6db6..16e06d7 100644 --- a/assets/ts/main.tsx +++ b/assets/ts/main.tsx @@ -13,6 +13,8 @@ import { render } from 'solid-js/web' import { getImageJSON } from './resources' import { StateProvider } from './state' +import '../scss/style.scss' + /** * interfaces */ diff --git a/exampleSite/config/_default/params.toml b/exampleSite/config/_default/params.toml index fc82038..2d7babf 100644 --- a/exampleSite/config/_default/params.toml +++ b/exampleSite/config/_default/params.toml @@ -1,9 +1,5 @@ # description of the site (will be placed in meta) description = "Bridget is a minimal Hugo theme designed for photographers/visual artists." -# use bundled js and css -# * if you want to build the js and css from scratch, set this to false and run `npm install` and `npm run build` -# * tldr: set this to false if you want to develop and edit the js and css -bundled = false # whether to use favicon resource links # generate these with https://realfavicongenerator.net diff --git a/layouts/partials/head/link.html b/layouts/partials/head/link.html index c5b64d4..0ea9bfb 100644 --- a/layouts/partials/head/link.html +++ b/layouts/partials/head/link.html @@ -7,16 +7,8 @@ {{- $style = dict "Context" . "ToCSS" $options "Inline" true | merge $style -}} {{- partial "plugin/style.html" $style -}} -{{/* main style */}} -{{- if (site.Params.bundled | default true) -}} - {{- $style := dict "Link" "/bundled/css/style.min.css" "Defer" true -}} - {{- partial "plugin/style.html" $style -}} -{{- else -}} - {{- $style := dict "Source" "scss/style.scss" "Fingerprint" $fingerprint -}} - {{- $options := dict "targetPath" "css/style.css" "enableSourceMap" true "includePaths" (slice "node_modules") -}} - {{- $style = dict "Context" . "ToCSS" $options "Minify" hugo.IsProduction "Defer" true | merge $style -}} - {{- partial "plugin/style.html" $style -}} -{{- end -}} +{{- $style := dict "Link" "/bundled/css/main.css" "Defer" true -}} +{{- partial "plugin/style.html" $style -}} {{/* fuck safari */}}