SvelteKitApp/sveltekitapp-chrome-extension-template
Репозиторий сгенерирован командой
npm create @svelte@latest
.
$npm i -D sveltekit-adapter-chrome-extension
# дополнительная зависимость для работы с TypeScript
$npm i -D @types/chrome
-import adapter from "sveltekit@adapter-auto";
+import adapter from "sveltekit-adapter-chrome-extension";
...
- adapter: adapter()
+ // @see https://github.com/michmich112/sveltekit-adapter-chrome-extension
+ adapter: adapter({
+ // default options are shown
+ pages: 'build',
+ assets: 'build',
+ fallback: null,
+ precompress: false,
+ manifest: 'manifest.json'
+ }),
+ appDir: 'app'
}
+layout.ts
для включения предварительной генерации страниц(ы) приложения (обязательное требование)$echo 'export const prerender = true;' >> ./src/routes/+layout.ts
manifest.json
$echo '{}' >> ./static/manifest.json
manifest.json
-{}
+{
+ "manifest_version": 3,
+ "version": "0.0.1",
+ "name": "sveltekitapp-chrome-extension-template",
+ "description": "Шаблон Chrome extension с использованием Sveltekit",
+ "icons": {
+ "32": "favicon.png"
+ },
+ "action": {
+ "default_popup": "index.html",
+ "default_icon": "favicon.png",
+ "default_title": "sveltekitapp-chrome-extension-template"
+ }
+}
Tailwind CSS
FrameworkTailwind CSS
$npx svelte-add@latest tailwindcss
$npm i
$npm i -D @skeletonlabs/skeleton
src/routes/+layout.svelte
# src/routes/+layout.svelte
+// Your selected Skeleton theme:
+import '@skeletonlabs/skeleton/themes/theme-skeleton.css';
+
+// This contains the bulk of Skeletons required styles:
+// NOTE: this will be renamed skeleton.css in the v2.x release.
+import '@skeletonlabs/skeleton/styles/skeleton.css';
+
+// Finally, your application's global stylesheet (sometimes labeled 'app.css')
import '../app.postcss';
tailwind.config.cjs
# tailwind.config.cjs
const config = {
- content: ['./src/**/*.{html,js,svelte,ts}'],
+ // 1. Apply the dark mode class setting:
+ darkMode: 'class',
+ content: [
+ './src/**/*.{html,js,svelte,ts}',
+ // 2. Append the path for the Skeleton NPM package and files:
+ require('path').join(require.resolve('@skeletonlabs/skeleton'), '../**/*.{html,js,svelte,ts}')
+ ],
theme: {
extend: {}
},
- plugins: []
+ plugins: [
+ // 3. Append the Skeleton plugin to the end of this list
+ ...require('@skeletonlabs/skeleton/tailwind/skeleton.cjs')()
+ ]
};
$npm run build
# предварительный просмотр сборки на странице браузера
$npm run preview
chrome://extensions/
./build
$npm i
npm run dev
# опция для открытия страницы в браузере
npm run dev -- --open