{"_id":"@alexander.k/vite-plugin-for-shopify","_rev":"5-0fa04305e7dce7316c11178ca2c2bced","name":"@alexander.k/vite-plugin-for-shopify","dist-tags":{"latest":"1.2.0"},"versions":{"1.0.0":{"name":"@alexander.k/vite-plugin-for-shopify","version":"1.0.0","keywords":["vite","plugin","shopify"],"author":{"name":"Alexander Kucherenko"},"license":"MIT","_id":"@alexander.k/vite-plugin-for-shopify@1.0.0","maintainers":[{"name":"alexander.k","email":"dif.kae@gmail.com"}],"homepage":"https://github.com/kucherenko-ae/vite-plugin-for-shopify#readme","bugs":{"url":"https://github.com/kucherenko-ae/vite-plugin-for-shopify/issues"},"dist":{"shasum":"c9b214c3e5be7338d2c063c02a0a1e5e7c51a189","tarball":"https://registry.npmjs.org/@alexander.k/vite-plugin-for-shopify/-/vite-plugin-for-shopify-1.0.0.tgz","fileCount":2,"integrity":"sha512-1f2uaKkZO3UVMy85cLZzQEn4MOI1y784OSkPwD/TkQ3d38zXc5D1n7OgnNv942i4jmF4GUUPiLoeu0x78fZ2bw==","signatures":[{"sig":"MEUCIAGUP91MK5Y1y7a5JoO7J21KW8FIa7SHfNytDOShn/BBAiEAsK3OTebNoPbKhNDNM4D/denAh0tKOal4jfphCQmKi8Y=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10253},"main":"./dist/index.js","gitHead":"bcbfd40255f1483ee369c7628b185b6cf63a157b","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexander.k","email":"dif.kae@gmail.com"},"repository":{"url":"git+https://github.com/kucherenko-ae/vite-plugin-for-shopify.git","type":"git"},"_npmVersion":"10.9.0","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-for-shopify_1.0.0_1730887695178_0.2916441721122114","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@alexander.k/vite-plugin-for-shopify","version":"1.0.1","keywords":["vite","vite-plugin","plugin","shopify","liquid"],"author":{"name":"Alexander Kucherenko"},"license":"MIT","_id":"@alexander.k/vite-plugin-for-shopify@1.0.1","maintainers":[{"name":"alexander.k","email":"dif.kae@gmail.com"}],"homepage":"https://github.com/kucherenko-ae/vite-plugin-for-shopify#readme","bugs":{"url":"https://github.com/kucherenko-ae/vite-plugin-for-shopify/issues"},"dist":{"shasum":"ffa2988e08c7c81fab5c442ad55c5685c22eadc4","tarball":"https://registry.npmjs.org/@alexander.k/vite-plugin-for-shopify/-/vite-plugin-for-shopify-1.0.1.tgz","fileCount":2,"integrity":"sha512-oBMOp4cZ9G0Zpa16VFdCWhC2bC0ykbzn6NTYD5gVS27x/3DIuLjAhjzTFr/RllpGFS8EiT9iSL+3Vqdg/XCc9w==","signatures":[{"sig":"MEUCIGNZeK818pIiM9rGHdRvqrJYcMsZcVhegZ+NQoum7K+hAiEAl05mi0N4thHr8G1HyGPCs7dnckcHftTBMegncSCtEe0=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":10294},"main":"./dist/index.mjs","gitHead":"86eefe2388fb0d3b0131aeb9a81678db911fd348","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexander.k","email":"dif.kae@gmail.com"},"repository":{"url":"git+https://github.com/kucherenko-ae/vite-plugin-for-shopify.git","type":"git"},"_npmVersion":"10.9.0","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-for-shopify_1.0.1_1730888701475_0.060280673137448115","host":"s3://npm-registry-packages"}},"1.1.0":{"name":"@alexander.k/vite-plugin-for-shopify","version":"1.1.0","keywords":["vite","vite-plugin","plugin","shopify","liquid"],"author":{"name":"Alexander Kucherenko"},"license":"MIT","_id":"@alexander.k/vite-plugin-for-shopify@1.1.0","maintainers":[{"name":"alexander.k","email":"dif.kae@gmail.com"}],"homepage":"https://github.com/kucherenko-ae/vite-plugin-for-shopify#readme","bugs":{"url":"https://github.com/kucherenko-ae/vite-plugin-for-shopify/issues"},"dist":{"shasum":"83077878b23271831bdb122e20182289fe8ef586","tarball":"https://registry.npmjs.org/@alexander.k/vite-plugin-for-shopify/-/vite-plugin-for-shopify-1.1.0.tgz","fileCount":3,"integrity":"sha512-oDuh0kMwA/lh6zr+EccyCWoC0bea9ee8K3x3hxgvyC01BQ8/OhZWnOHfNQtaQLNXuPKgOweWp0v4t70doe89aw==","signatures":[{"sig":"MEQCIDsMaSmOtEE1GE3YpFsfaeytwdhIgnbhEUqJkJU7bYZGAiBtclMMC0dxGEAt1Pmt9jv+YY23FinVMXkmeWq5WLRKjQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14867},"main":"./dist/index.mjs","gitHead":"2fa848f3691c9f37487cd5880d9bd2df48ffdee4","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexander.k","email":"dif.kae@gmail.com"},"repository":{"url":"git+https://github.com/kucherenko-ae/vite-plugin-for-shopify.git","type":"git"},"_npmVersion":"10.9.2","description":"Vite plugin for generate snippet with all inputs (entries).","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-for-shopify_1.1.0_1733986417602_0.03308221273465839","host":"s3://npm-registry-packages-npm-production"}},"1.1.1":{"name":"@alexander.k/vite-plugin-for-shopify","version":"1.1.1","keywords":["vite","vite-plugin","plugin","shopify","liquid"],"author":{"name":"Alexander Kucherenko"},"license":"MIT","_id":"@alexander.k/vite-plugin-for-shopify@1.1.1","maintainers":[{"name":"alexander.k","email":"dif.kae@gmail.com"}],"homepage":"https://github.com/kucherenko-ae/vite-plugin-for-shopify#readme","bugs":{"url":"https://github.com/kucherenko-ae/vite-plugin-for-shopify/issues"},"dist":{"shasum":"1d9a34d57ff790d755047c67d3a35e37231f2fdd","tarball":"https://registry.npmjs.org/@alexander.k/vite-plugin-for-shopify/-/vite-plugin-for-shopify-1.1.1.tgz","fileCount":3,"integrity":"sha512-EYCp4CyHH+7GneMxzwbc4NTtTw3FPFem3VEHyoh0dAxiPl+22WyLWHG9xBkA/fvOQyjkjQT7MNG6aGWlwaKcdA==","signatures":[{"sig":"MEUCIQDEvOzdmu4NrkZ093gqH6iJAZrXtDGgYRCivk94BrFJLwIgcOmlHmyup/+XMIS7nZXjFWAiCcJTFYvEs+3berWODjs=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":14934},"main":"./dist/index.mjs","gitHead":"ac82002fe44e1484a298a39c62a815b7bcc3502d","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"alexander.k","email":"dif.kae@gmail.com"},"repository":{"url":"git+https://github.com/kucherenko-ae/vite-plugin-for-shopify.git","type":"git"},"_npmVersion":"10.9.2","description":"Vite plugin for generate snippet with all inputs (entries).","directories":{},"_nodeVersion":"22.11.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/vite-plugin-for-shopify_1.1.1_1733987119228_0.6719125435580606","host":"s3://npm-registry-packages-npm-production"}},"1.2.0":{"name":"@alexander.k/vite-plugin-for-shopify","version":"1.2.0","main":"./dist/index.mjs","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/kucherenko-ae/vite-plugin-for-shopify.git"},"keywords":["vite","vite-plugin","plugin","shopify","liquid"],"author":{"name":"Alexander Kucherenko"},"license":"MIT","bugs":{"url":"https://github.com/kucherenko-ae/vite-plugin-for-shopify/issues"},"homepage":"https://github.com/kucherenko-ae/vite-plugin-for-shopify#readme","description":"Vite plugin to generate a Shopify Liquid snippet with all Vite build entries.","_id":"@alexander.k/vite-plugin-for-shopify@1.2.0","gitHead":"7ece69eed0eb614bc4232969fd17913c55519c8f","_nodeVersion":"22.11.0","_npmVersion":"11.3.0","dist":{"integrity":"sha512-eGGx7KQNjrH8IE9dHmOCEVW99PHXxCylXv4sk9O6bU9gPVflU4tKM99+oi4MDpd6Nnxl9BNNhlBj9mgZBQYQ2A==","shasum":"c33a4c29e436ddbeb8b6562b5fb54837deef051e","tarball":"https://registry.npmjs.org/@alexander.k/vite-plugin-for-shopify/-/vite-plugin-for-shopify-1.2.0.tgz","fileCount":3,"unpackedSize":16987,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDRncgddUidD/VWvZB5Jq0Fg73nNFFTubxqqpUWz2f7IAIhALGibA4YOf6YLfJ0pZZeF6IvhrdIuHPeixqeyWftPYgl"}]},"_npmUser":{"name":"alexander.k","email":"dif.kae@gmail.com"},"directories":{},"maintainers":[{"name":"alexander.k","email":"dif.kae@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/vite-plugin-for-shopify_1.2.0_1748421916100_0.12805391078817796"},"_hasShrinkwrap":false}},"time":{"created":"2024-11-06T10:08:15.003Z","modified":"2025-05-28T08:45:16.491Z","1.0.0":"2024-11-06T10:08:15.324Z","1.0.1":"2024-11-06T10:25:01.632Z","1.1.0":"2024-12-12T06:53:37.770Z","1.1.1":"2024-12-12T07:05:19.371Z","1.2.0":"2025-05-28T08:45:16.321Z"},"bugs":{"url":"https://github.com/kucherenko-ae/vite-plugin-for-shopify/issues"},"author":{"name":"Alexander Kucherenko"},"license":"MIT","homepage":"https://github.com/kucherenko-ae/vite-plugin-for-shopify#readme","keywords":["vite","vite-plugin","plugin","shopify","liquid"],"repository":{"type":"git","url":"git+https://github.com/kucherenko-ae/vite-plugin-for-shopify.git"},"description":"Vite plugin to generate a Shopify Liquid snippet with all Vite build entries.","maintainers":[{"name":"alexander.k","email":"dif.kae@gmail.com"}],"readme":"# vite-plugin-for-shopify\n\nVite plugin to generate a Shopify Liquid snippet with all Vite build entries.\n\n## Features\n\n- Generates a Liquid snippet (default: `vite.liquid`) in your theme's `snippets` directory\n- Cleans up old asset files in the output directory if they no longer exist in the new build (optional)\n- Supports dynamic imports in Shopify themes via a helper function\n\n## Installation\n\nAdd the plugin to your project:\n\n```sh\nnpm install @alexander.k/vite-plugin-for-shopify --save-dev\n```\n\n## Usage\n\n### Add the plugin to your `vite.config.js`\n\nAll options are optional:\n\n```js\nimport shopifyVitePlugin from '@alexander.k/vite-plugin-for-shopify'\n\nexport default {\n  plugins: [\n    shopifyVitePlugin({\n      // Root path to your Shopify theme (default: './')\n      themeRoot: './',\n      // Name of the snippet file to generate (default: 'vite.liquid')\n      snippetFilename: 'vite.liquid',\n      cleanup: {\n        // Regex to match files in the assets folder generated by Vite.\n        // Old files matching this pattern will be removed after each build.\n        // If not set, old files will not be deleted.\n        fileNameRegex: /.*\\.min\\.(js|css)$/m\n      }\n    })\n  ]\n}\n```\n\n> Note: The `fileNameRegex` option can also be provided at the root level for backward compatibility, but it is recommended to use the `cleanup` object.\n\n### Add the snippet to `<head></head>` once (no params)\n\nThis will add the helper function for dynamic imports to your code. For example, add to your `theme.liquid` file:\n\n```liquid\n<html>\n  <head>\n    ...\n    {% render 'vite' %}\n  </head>\n  <body>\n    ...\n  </body>\n</html>\n```\n\n### Use the snippet with entry name as in your Vite inputs\n\nExample Vite config:\n\n```js\nexport default defineConfig({\n  plugins: [\n    shopifyVitePlugin()\n  ],\n  build: {\n    rollupOptions: {\n      input: {\n        theme: './some-path/theme.js',\n        coolSection: './some-path/coolSection.js',\n        utils: './some-path/utils.js',\n        pageStyles: './some-path/pageStyles.css'\n      }\n    }\n  }\n})\n```\n\n#### Default usage\n\n```liquid\n{% liquid\n  # You can also preload styles\n  render 'vite', entry: 'theme', preload_stylesheet: true\n  render 'vite', entry: 'pageStyles'\n  render 'vite', entry: 'coolSection'\n%}\n```\n\n#### Only styles or only JS\n\n```liquid\n{% liquid\n  # Only styles\n  render 'vite', entry: 'theme', only_css: true\n  # Only JS\n  render 'vite', entry: 'coolSection', only_js: true\n%}\n```\n\n#### Import mode for styles\n\n```liquid\n<template class=\"component-template\">\n  <style>\n    {% render 'vite', entry: 'theme', only_css: true, import_mode: true %}\n    :root {\n      display: block;\n    }\n    .wrapper {\n      padding: 10px;\n    }\n  </style>\n  <div class=\"wrapper\">\n    <button class=\"global-class-from-theme\">Button</button>\n  </div>\n</template>\n```\n\n==> result:\n\n```html\n<template class=\"component-template\">\n  <style>\n    @import url(\"//www.your-store.com/cdn/shop/t/111/assets/theme.C0CJB5x1.min.css\");\n    :root {\n      display: block;\n    }\n    .wrapper {\n      padding: 10px;\n    }\n  </style>\n  <div class=\"wrapper\">\n    <button class=\"global-class-from-theme\">Button</button>\n  </div>\n</template>\n```\n\n#### Import mode for JS\n\n```liquid\n<script type=\"module\">\n  {% render 'vite', entry: 'utils', only_js: true, import_mode: true %}\n</script>\n```\n\n==> result:\n\n```html\n<script type=\"module\">\n  import \"//www.your-store.com/cdn/shop/t/111/assets/utils.C0CJB5x1.min.js\";\n</script>\n```\n\nOr named import:\n\n```liquid\n<script type=\"module\">\n  {% render 'vite', entry: 'utils', only_js: true, import_mode: true, import_name: '{ getCart }' %}\n\n  const cart = getCart()\n</script>\n```\n\n==> result:\n\n```html\n<script type=\"module\">\n  import { getCart } from \"//www.your-store.com/cdn/shop/t/111/assets/utils.C0CJB5x1.min.js\";\n\n  const cart = getCart()\n</script>\n```\n\nOr dynamic way:\n\n```liquid\n<script type=\"module\">\n  const addClickHandler = async (items) => {\n    {% render 'vite', entry: 'utils', only_js: true, import_mode: true, dynamic_import: true, import_name: '{ addToCart }' %}\n\n    return await addToCart(items)\n  }\n</script>\n```\n\n==> result:\n\n```html\n<script type=\"module\">\n  const addClickHandler = async (items) => {\n    const { addToCart } = await import(\"//www.your-store.com/cdn/shop/t/111/assets/utils.C0CJB5x1.min.js\");\n\n    return await addToCart(items)\n  }\n</script>\n```\n\n---\n\n## How it works\n\n- The plugin generates a snippet file (default: `vite.liquid`) in your theme's `snippets` directory after each build.\n- The snippet contains all entry points from your Vite config and supports various usage modes (see above).\n- If the `cleanup.fileNameRegex` option is set, the plugin will remove old files in the output directory that do not exist in the new build.\n- The plugin automatically removes the manifest file after build (except in development mode).\n- For dynamic imports, a helper function is injected into the global scope to resolve asset URLs correctly.\n\n---\n\n## Notes\n\n- The snippet is auto-generated. Do not edit it manually.\n- Make sure to commit the snippet file if you want to keep it in version control.\n- For more details, see the comments in the generated snippet or the plugin source code.","readmeFilename":"README.md"}