From 383f82807f4090bdd2c3dcdc695b75093b854031 Mon Sep 17 00:00:00 2001 From: Philipp Dormann Date: Sun, 17 Jan 2021 18:16:02 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20improved=20dev=20scripts=20for=20sp?= =?UTF-8?q?eed=20starts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.template.html | 23 +++++++++++++++++++++++ package.json | 6 ++++-- public/index.html | 23 +---------------------- s-config.template.js | 6 ++++++ svelte.config.js | 12 +----------- template-copy.js | 22 ++++++++++++++++++++++ 6 files changed, 57 insertions(+), 35 deletions(-) create mode 100644 index.template.html create mode 100644 s-config.template.js create mode 100644 template-copy.js diff --git a/index.template.html b/index.template.html new file mode 100644 index 00000000..9cf1a0ae --- /dev/null +++ b/index.template.html @@ -0,0 +1,23 @@ + + + + + + + + + + + + Lauf für Kaya! - Admin + __TAILWIND_INSERT__ + + + + + + + + + + \ No newline at end of file diff --git a/package.json b/package.json index 70a60a51..6daf680d 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,9 @@ "version": "0.3.1", "scripts": { "i18n-order": "node order.js", - "dev": "snowpack dev", - "build": "snowpack build", + "dev:all": "cross-env NODE_ENV_ODIT=production && node template-copy.js && snowpack dev", + "dev:fast": "cross-env NODE_ENV_ODIT=development_fast && node template-copy.js && snowpack dev", + "build": "cross-env NODE_ENV_ODIT=production && node template-copy.js && snowpack build", "build:sw": "workbox generateSW workbox-config.js", "release": "release-it", "licenses:export": "license-exporter --json -o public" @@ -28,6 +29,7 @@ "@snowpack/plugin-svelte": "3.5.1", "auto-changelog": "^2.2.1", "autoprefixer": "10.2.1", + "cross-env": "^7.0.3", "postcss": "8.2.4", "postcss-load-config": "3.0.0", "release-it": "^14.2.2", diff --git a/public/index.html b/public/index.html index 8227a0e1..1b0be8ea 100644 --- a/public/index.html +++ b/public/index.html @@ -1,22 +1 @@ - - - - - - - - - - - - Lauf für Kaya! - Admin - - - - - - - - - - \ No newline at end of file + \ No newline at end of file diff --git a/s-config.template.js b/s-config.template.js new file mode 100644 index 00000000..1807630b --- /dev/null +++ b/s-config.template.js @@ -0,0 +1,6 @@ +const sveltePreprocess = require('svelte-preprocess'); +const preprocess = sveltePreprocess(__insert__); + +module.exports = { + preprocess +}; diff --git a/svelte.config.js b/svelte.config.js index c331e4a8..37be7df6 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,11 +1 @@ -const sveltePreprocess = require('svelte-preprocess'); - -const preprocess = sveltePreprocess({ - postcss: { - plugins: [ require('tailwindcss'), require('autoprefixer') ] - } -}); - -module.exports = { - preprocess -}; +// this is configured with dev scripts diff --git a/template-copy.js b/template-copy.js new file mode 100644 index 00000000..6a46cd71 --- /dev/null +++ b/template-copy.js @@ -0,0 +1,22 @@ +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');