diff --git a/.gitignore b/.gitignore index b2496c6e..ebb9406e 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,5 @@ yarn.lock public/env.js public/sw.js public/index.html -public/workbox-*.js svelte.config.js public/index.html diff --git a/index.template.html b/index.html similarity index 86% rename from index.template.html rename to index.html index 7a819098..282c691c 100644 --- a/index.template.html +++ b/index.html @@ -1,23 +1,22 @@ - - - - - - - - - - - - Lauf für Kaya! - Admin - __TAILWIND_INSERT__ - - - - - - - - - + + + + + + + + + + + + Lauf für Kaya! - Admin + + + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json index 116f1990..ee1780cf 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,8 @@ "version": "0.8.4", "scripts": { "i18n-order": "node order.js", - "dev:all": "yarn prebuild && snowpack dev", - "dev": "cross-env NODE_ENV_ODIT=development_fast node template-copy.js && yarn build:sw && snowpack dev", - "build": "yarn prebuild && snowpack build", - "prebuild": "cross-env NODE_ENV_ODIT=production node template-copy.js && yarn build:sw", - "build:sw": "workbox generateSW workbox-config.js", + "dev": "vite dev", + "build": "vite build", "release": "release-it", "licenses:export": "license-exporter --json -o public" }, @@ -29,17 +26,19 @@ }, "devDependencies": { "@odit/license-exporter": "^0.0.11", - "@snowpack/plugin-svelte": "3.5.2", "auto-changelog": "^2.2.1", "autoprefixer": "10.2.5", "cross-env": "^7.0.3", "postcss": "8.2.8", "postcss-load-config": "3.0.1", "release-it": "^14.4.1", - "snowpack": "3.0.13", "svelte": "3.35.0", "svelte-preprocess": "4.6.9", - "workbox-cli": "6.1.2" + "vite": "^2.1.2", + "vite-plugin-windicss": "^0.9.6", + "@svitejs/vite-plugin-svelte": "^0.11.1", + "@types/html-minifier": "^4.0.0", + "html-minifier": "^4.0.0" }, "release-it": { "git": { @@ -55,7 +54,7 @@ "publish": false }, "hooks": { - "after:bump": "npx auto-changelog --commit-limit false -p -u --hide-credit && git add CHANGELOG.md && node versionbuilder.js && git add index.template.html && node order.js && git add src/locales" + "after:bump": "npx auto-changelog --commit-limit false -p -u --hide-credit && git add CHANGELOG.md && node versionbuilder.js && git add index.html && node order.js && git add src/locales" } } } diff --git a/s-config.template.js b/s-config.template.js deleted file mode 100644 index 1807630b..00000000 --- a/s-config.template.js +++ /dev/null @@ -1,6 +0,0 @@ -const sveltePreprocess = require('svelte-preprocess'); -const preprocess = sveltePreprocess(__insert__); - -module.exports = { - preprocess -}; diff --git a/snowpack.config.js b/snowpack.config.js deleted file mode 100644 index a1be08ab..00000000 --- a/snowpack.config.js +++ /dev/null @@ -1,26 +0,0 @@ -/** @type {import("snowpack").SnowpackUserConfig } */ -module.exports = { - mount: { - public: '/', - src: '/_dist_' - }, - plugins: [ '@snowpack/plugin-svelte' ], - routes: [ - /* Enable an SPA Fallback in development: */ - { match: 'routes', src: '.*', dest: '/index.html' } - ], - packageOptions: { - /* ... */ - sourceMap: false - }, - devOptions: { - /* ... */ - }, - buildOptions: { - /* ... */ - }, - alias: { - /* ... */ - }, - optimize: { bundle: true, minify: true } -}; diff --git a/tailwind.config.js b/tailwind.config.js index 495e28cc..6ad85dad 100644 --- a/tailwind.config.js +++ b/tailwind.config.js @@ -1,14 +1,13 @@ module.exports = { - purge: { - content: [ './src/**/*.svelte' ] - }, - // darkMode: 'media', - variants: {}, - plugins: [], theme: { - container: { - center: true, - padding: '1.5rem' + extend: { + colors: { + reepolee: { + 500: '#b40000', + 600: '#9c0000', + 700: '#750000' + } + } } } }; diff --git a/template-copy.js b/template-copy.js deleted file mode 100644 index 1f1ca3dc..00000000 --- a/template-copy.js +++ /dev/null @@ -1,19 +0,0 @@ -const fs = require('fs'); -let content_svelteconfig = fs.readFileSync('./s-config.template.js', { encoding: 'utf8' }); -let content_html = fs.readFileSync('./index.template.html', { encoding: 'utf8' }); -if (process.env.NODE_ENV_ODIT == 'development_fast') { - content_html = content_html.replace( - '__TAILWIND_INSERT__', - '' - ); - content_svelteconfig = content_svelteconfig.replace('__insert__', '{postcss:{}}'); -} else { - content_html = content_html.replace('__TAILWIND_INSERT__', ''); - content_svelteconfig = content_svelteconfig.replace( - '__insert__', - "{postcss:{plugins:[require('tailwindcss'),require('autoprefixer')]}}" - ); -} -fs.writeFileSync('./public/index.html', content_html); -fs.writeFileSync('./svelte.config.js', content_svelteconfig); -console.info('dev setup script done'); diff --git a/versionbuilder.js b/versionbuilder.js index 339b1962..0e07c9ee 100644 --- a/versionbuilder.js +++ b/versionbuilder.js @@ -1,5 +1,5 @@ const fs = require('fs'); const package = JSON.parse(fs.readFileSync(`./package.json`, { encoding: 'utf-8' })); -const original = fs.readFileSync(`./index.template.html`, { encoding: 'utf-8' }); +const original = fs.readFileSync(`./index.html`, { encoding: 'utf-8' }); let out = original.replace(/RELEASE_INFO-(\S)+-RELEASE_INFO/gi, 'RELEASE_INFO-' + package.version + '-RELEASE_INFO'); -fs.writeFileSync(`./index.template.html`, out); +fs.writeFileSync(`./index.html`, out); diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 00000000..0b6f2a27 --- /dev/null +++ b/vite.config.js @@ -0,0 +1,50 @@ +import svelte from '@svitejs/vite-plugin-svelte'; +import windiCSS from 'vite-plugin-windicss'; +import { minify } from 'html-minifier'; +import { defineConfig } from 'vite'; +// +const indexReplace = () => { + return { + name: 'html-transform', + transformIndexHtml(html) { + return minify(html, { + collapseWhitespace: true + }); + } + }; +}; + +export default defineConfig(({ command, mode }) => { + const isProduction = mode === 'production'; + return { + base: './', + build: { + polyfillDynamicImport: false, + cssCodeSplit: false, + minify: isProduction + }, + plugins: [ + windiCSS({ + //@ts-ignore + verbose: true, + silent: false, + debug: true, + config: 'tailwind.config.js', // tailwind config file path (optional) + compile: false, // false: interpretation mode; true: compilation mode + prefix: 'windi-', // set compilation mode style prefix + globalPreflight: true, // set preflight style is global or scoped + globalUtility: true // set utility style is global or scoped + }), + svelte({ + //@ts-ignore + hot: !isProduction, + emitCss: true, + extensions: [ '.md', '.svx', '.svelte' ], + preprocess: [ + // + ] + }), + indexReplace() + ] + }; +}); diff --git a/workbox-config.js b/workbox-config.js deleted file mode 100644 index 368c3575..00000000 --- a/workbox-config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - globDirectory: 'public', - globPatterns: [ '**/*.{js,ico,png,svg,html,webmanifest,txt,json}' ], - globIgnores: [ 'env.js', 'env.sample.js' ], - swDest: 'public/sw.js', - cleanupOutdatedCaches: true, - mode: 'production', - sourcemap: false -};