npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tanc00/vite-plugin-sfc-reload

v0.0.5

Published

Trigger a HMR update on CSS or JS changes or a full page reload when templates are modified

Downloads

6

Readme

Based on the vite-plugin-full-reload plugin and adapted for use with SFC Drupal files: vite-plugin-full-reload

Why?

When developing a Drupal theme based on Single File Components it can be very useful to have both Hot Module Reloads of the CSS files as well as full page reloads if the <template> section changes. This plugin will watch the SFC files for changes and POST the changed component name to the sfc/compile callback which in turn will report back which section of the file was updated. Then the plugin decides whether the HMR is sufficient (it does nothing as HMR is already take care of) or if it should trigger a full page refresh which is needed to display template changes.

Installation 💿

Install the package as a development dependency:

npm i -D vite-plugin-sfc-reload # yarn add -D vite-plugin-sfc-reload

Usage 🚀

Add it to your plugins in vite.config.ts

import { defineConfig } from 'vite'
import SfcReload from 'vite-plugin-sfc-reload'

export default defineConfig({
  plugins: [
    SfcReload(['components/**/*.sfc'], {
      domain: 'http://yourlocaldomain.dev',
    }),
  ],
})

This is useful to trigger a page refresh for files that are not being imported, such as server-rendered templates.

To see which file globbing options are available, check [picomatch].

Configuration ⚙️

The following options can be provided:

  • domain

    The local development domain where the sfc_dev module is installed and responding on /sfc/compile

    Default: http://localhost

  • root

    Files will be resolved against this directory.

    Default: process.cwd()

    SfcReload('components/**/*.sfc', { root: __dirname }),
  • delay

    How many milliseconds to wait before reloading the page after a file change. It can be used to offset slow template compilation in Rails.

    Default: 0

    SfcReload('components/**/*.sfc', { delay: 100 })
  • always

    Whether to refresh the page even if the modified HTML file is not currently being displayed.

    Default: true

    SfcReload('components/**/*.sfc', { always: false })

Acknowledgements

License

This library is available as open source under the terms of the MIT License.