pixel-mirror 1.0.3 → 1.0.4
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/README.md +40 -5
- package/package.json +10 -3
- package/plugins/astro.d.ts +5 -0
- package/plugins/astro.js +18 -0
- package/plugins/vite.d.ts +5 -0
- package/plugins/vite.js +3 -3
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ Pixel Mirror is a lightweight tool for front-end developers that overlays design
|
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
|
-
### 1. For Vite projects
|
|
9
|
+
### 1. For [Vite](https://vite.dev/) projects
|
|
10
10
|
|
|
11
11
|
Install the package via npm:
|
|
12
12
|
|
|
@@ -17,20 +17,55 @@ npm install pixel-mirror --save-dev
|
|
|
17
17
|
Then, add Pixel Mirror's Vite plugin to your `vite.config.js`:
|
|
18
18
|
|
|
19
19
|
```js
|
|
20
|
-
import pixelMirrorPlugin from "pixel-mirror/vite";
|
|
21
20
|
import { defineConfig } from "vite";
|
|
21
|
+
import pixelMirror from "pixel-mirror/vite";
|
|
22
22
|
|
|
23
23
|
export default defineConfig({
|
|
24
|
-
plugins: [
|
|
24
|
+
plugins: [pixelMirror()],
|
|
25
25
|
// ... other configurations
|
|
26
26
|
});
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
The plugin is automatically injected into your HTML during development and will be removed in production builds.
|
|
30
30
|
|
|
31
|
-
### 2. For
|
|
31
|
+
### 2. For [Astro](https://astro.build/) projects
|
|
32
32
|
|
|
33
|
-
|
|
33
|
+
Install the package via npm:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
npm install pixel-mirror --save-dev
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Then, add Pixel Mirror's Astro Integration to your `astro.config.mjs`:
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
import { defineConfig } from "astro/config";
|
|
43
|
+
import pixelMirror from "pixel-mirror/astro";
|
|
44
|
+
|
|
45
|
+
export default defineConfig({
|
|
46
|
+
integrations: [pixelMirror()],
|
|
47
|
+
// ... other configurations
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 3. For [Next.js](https://nextjs.org/) projects
|
|
52
|
+
|
|
53
|
+
Inject the following code to the `<Head></Head>` section in `_document.jsx`:
|
|
54
|
+
|
|
55
|
+
``` jsx
|
|
56
|
+
// import Script from "next/script"
|
|
57
|
+
|
|
58
|
+
{process.env.NODE_ENV === "development" && (
|
|
59
|
+
<Script
|
|
60
|
+
src="https://cdn.jsdelivr.net/npm/pixel-mirror/dist/index.js"
|
|
61
|
+
strategy="afterInteractive"
|
|
62
|
+
/>
|
|
63
|
+
)}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### 4. For other projects
|
|
67
|
+
|
|
68
|
+
Integrate Pixel Mirror by injecting its script into your HTML:
|
|
34
69
|
|
|
35
70
|
``` html
|
|
36
71
|
<script defer src="https://cdn.jsdelivr.net/npm/pixel-mirror/dist/index.js"></script>
|
package/package.json
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pixel-mirror",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Pixel Mirror helps developers achieve pixel-perfect UIs by easily overlaying design mockups.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dist/index.js",
|
|
8
|
-
"./vite":
|
|
8
|
+
"./vite": {
|
|
9
|
+
"types": "./plugins/vite.d.ts",
|
|
10
|
+
"default": "./plugins/vite.js"
|
|
11
|
+
},
|
|
12
|
+
"./astro": {
|
|
13
|
+
"types": "./plugins/astro.d.ts",
|
|
14
|
+
"default": "./plugins/astro.js"
|
|
15
|
+
}
|
|
9
16
|
},
|
|
10
17
|
"keywords": [
|
|
11
18
|
"solid",
|
|
@@ -47,7 +54,7 @@
|
|
|
47
54
|
},
|
|
48
55
|
"lint-staged": {
|
|
49
56
|
"*.{ts,tsx}": [
|
|
50
|
-
"eslint --fix --max-warnings 0
|
|
57
|
+
"eslint --fix --max-warnings 0"
|
|
51
58
|
],
|
|
52
59
|
"*.scss": [
|
|
53
60
|
"stylelint --fix"
|
package/plugins/astro.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function pixelMirror() {
|
|
2
|
+
return {
|
|
3
|
+
name: "pixel-mirror",
|
|
4
|
+
hooks: {
|
|
5
|
+
"astro:config:setup": ({ command, injectScript }) => {
|
|
6
|
+
if (command === "dev") {
|
|
7
|
+
injectScript(
|
|
8
|
+
"head-inline",
|
|
9
|
+
`const script = document.createElement("script");
|
|
10
|
+
script.src = "/node_modules/pixel-mirror/dist/index.js";
|
|
11
|
+
script.defer = true;
|
|
12
|
+
document.head.appendChild(script);`
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
}
|
package/plugins/vite.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export default function
|
|
1
|
+
export default function pixelMirror() {
|
|
2
2
|
return {
|
|
3
|
-
name: "
|
|
3
|
+
name: "pixel-mirror",
|
|
4
4
|
transformIndexHtml(html) {
|
|
5
5
|
if (process.env.NODE_ENV !== "production") {
|
|
6
|
-
return html.replace("</
|
|
6
|
+
return html.replace("</head>", `<script defer src="/node_modules/pixel-mirror/dist/index.js"></script></head>`);
|
|
7
7
|
}
|
|
8
8
|
return html;
|
|
9
9
|
}
|