@unocss/astro 0.45.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021-PRESENT Anthony Fu <https://github.com/antfu>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # @unocss/astro
2
+
3
+ The UnoCSS integration for [Astro](https://astro.build/). Check [the example](../../examples/astro/).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm i -D unocss
9
+ ```
10
+
11
+ ```ts
12
+ // astro.config.ts
13
+ import Unocss from 'unocss/astro'
14
+
15
+ export default {
16
+ integrations: [
17
+ Unocss({ /* options */ }),
18
+ ],
19
+ }
20
+ ```
21
+
22
+ ### Presetless usage
23
+
24
+ > This plugin does not come with any default presets.
25
+ > If you are building a meta framework on top of UnoCSS, see [this file](https://github.com/unocss/unocss/blob/main/packages/unocss/src/astro.ts) for an example to bind the default presets.
26
+
27
+ ```bash
28
+ npm i -D @unocss/astro
29
+ ```
30
+
31
+ ```ts
32
+ // astro.config.mjs
33
+ import Unocss from '@unocss/astro'
34
+
35
+ export default {
36
+ integrations: [
37
+ Unocss({
38
+ presets: [
39
+ /* no presets by default */
40
+ ],
41
+ /* options */
42
+ }),
43
+ ],
44
+ }
45
+ ```
46
+
47
+ for more details, please refer to the [Vite plugin](../vite).
48
+
49
+ ## License
50
+
51
+ MIT License &copy; 2021-PRESENT [Anthony Fu](https://github.com/antfu)
package/dist/index.cjs ADDED
@@ -0,0 +1,36 @@
1
+ 'use strict';
2
+
3
+ const VitePlugin = require('@unocss/vite');
4
+
5
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
6
+
7
+ const VitePlugin__default = /*#__PURE__*/_interopDefaultLegacy(VitePlugin);
8
+
9
+ function UnoCSSAstroIntegration(options = {}, defaults) {
10
+ const {
11
+ injectEntry = true,
12
+ injectReset: includeReset = true
13
+ } = options;
14
+ return {
15
+ name: "unocss",
16
+ hooks: {
17
+ "astro:config:setup": async ({ config, injectScript }) => {
18
+ var _a;
19
+ (_a = config.vite).plugins || (_a.plugins = []);
20
+ config.vite.plugins.push(...VitePlugin__default(options, defaults));
21
+ const injects = [];
22
+ if (includeReset) {
23
+ const resetPath = typeof includeReset === "string" ? includeReset : "@unocss/reset/tailwind.css";
24
+ injects.push(`import "${resetPath}"`);
25
+ }
26
+ if (injectEntry) {
27
+ injects.push(typeof injectEntry === "string" ? injectEntry : 'import "uno.css"');
28
+ }
29
+ if (injects?.length)
30
+ injectScript("page-ssr", injects.join("\n"));
31
+ }
32
+ }
33
+ };
34
+ }
35
+
36
+ module.exports = UnoCSSAstroIntegration;
@@ -0,0 +1,20 @@
1
+ import { AstroIntegration } from 'astro';
2
+ import { VitePluginConfig } from '@unocss/vite';
3
+ import { UserConfigDefaults } from '@unocss/core';
4
+
5
+ interface AstroIntegrationConfig<Theme extends {} = {}> extends VitePluginConfig<Theme> {
6
+ /**
7
+ * Include reset styles
8
+ * When passing `true`, `@unocss/reset/tailwind.css` will be used
9
+ * @default true
10
+ */
11
+ injectReset?: string | boolean;
12
+ /**
13
+ * Inject UnoCSS entry import for every astro page
14
+ * @default true
15
+ */
16
+ injectEntry?: boolean | string;
17
+ }
18
+ declare function UnoCSSAstroIntegration<Theme extends {}>(options?: AstroIntegrationConfig<Theme>, defaults?: UserConfigDefaults): AstroIntegration;
19
+
20
+ export { AstroIntegrationConfig, UnoCSSAstroIntegration as default };
package/dist/index.mjs ADDED
@@ -0,0 +1,30 @@
1
+ import VitePlugin from '@unocss/vite';
2
+
3
+ function UnoCSSAstroIntegration(options = {}, defaults) {
4
+ const {
5
+ injectEntry = true,
6
+ injectReset: includeReset = true
7
+ } = options;
8
+ return {
9
+ name: "unocss",
10
+ hooks: {
11
+ "astro:config:setup": async ({ config, injectScript }) => {
12
+ var _a;
13
+ (_a = config.vite).plugins || (_a.plugins = []);
14
+ config.vite.plugins.push(...VitePlugin(options, defaults));
15
+ const injects = [];
16
+ if (includeReset) {
17
+ const resetPath = typeof includeReset === "string" ? includeReset : "@unocss/reset/tailwind.css";
18
+ injects.push(`import "${resetPath}"`);
19
+ }
20
+ if (injectEntry) {
21
+ injects.push(typeof injectEntry === "string" ? injectEntry : 'import "uno.css"');
22
+ }
23
+ if (injects?.length)
24
+ injectScript("page-ssr", injects.join("\n"));
25
+ }
26
+ }
27
+ };
28
+ }
29
+
30
+ export { UnoCSSAstroIntegration as default };
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@unocss/astro",
3
+ "version": "0.45.12",
4
+ "description": "UnoCSS integration for Astro",
5
+ "author": "Anthony Fu <anthonyfu117@hotmail.com>",
6
+ "license": "MIT",
7
+ "funding": "https://github.com/sponsors/antfu",
8
+ "homepage": "https://github.com/unocss/unocss#readme",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/unocss/unocss.git",
12
+ "directory": "packages/astro"
13
+ },
14
+ "bugs": {
15
+ "url": "https://github.com/unocss/unocss/issues"
16
+ },
17
+ "keywords": [
18
+ "unocss",
19
+ "astro",
20
+ "astro-integration",
21
+ "astro-component",
22
+ "css",
23
+ "ui"
24
+ ],
25
+ "sideEffects": false,
26
+ "exports": {
27
+ ".": {
28
+ "require": "./dist/index.cjs",
29
+ "import": "./dist/index.mjs"
30
+ }
31
+ },
32
+ "main": "./dist/index.cjs",
33
+ "module": "./dist/index.mjs",
34
+ "types": "./dist/index.d.ts",
35
+ "files": [
36
+ "dist"
37
+ ],
38
+ "dependencies": {
39
+ "@unocss/core": "0.45.12",
40
+ "@unocss/reset": "0.45.12",
41
+ "@unocss/vite": "0.45.12"
42
+ },
43
+ "devDependencies": {
44
+ "astro": "^1.0.6"
45
+ },
46
+ "scripts": {
47
+ "build": "unbuild",
48
+ "stub": "unbuild --stub"
49
+ }
50
+ }