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

vue-cli-plugin-html-replace

v1.3.0

Published

A simple plugin to replace contents within your HTML files generated by Vue CLI.

Downloads

2,067

Readme

npm version GitHub license

Vue-cli Plugin HTML Replace

A simple plugin to replace contents within your HTML files generated by Vue CLI.

Getting started

:warning: Make sure you have Vue CLI 3.x.x installed:

vue -V

Navigate to your vue app folder and add the cli plugin:

vue add html-replace

Configuration

Basic usage

This plugin can be configured by defining htmlReplace via the pluginOptions in your vue.config.js.

The patterns property must either be an object or an array of objects. Each pattern must contain both match and replacement options, otherwise it will be ignored.

module.exports = {
    pluginOptions: {
        htmlReplace: {
            enable: (process.env.NODE_ENV === "production"),
            patterns: [
                {
                    match: "foo",
                    replacement: "bar",
                },
                {
                    match: /any/g,
                    replacement: "Globally replaced",
                },
                {
                    match: /<title>(.*)<\/title>/,
                    replacement: (match, $1) => `<title>"${$1}" has been replaced.</title>`,
                },
            ],
        },
    },
};

Multi-page mode

In case you'd need to prevent patterns to be applied to some of your pages, you can specify either one of excludes or includes options. If both options are set, then excludes will be ignored.

Each entry must be named after the key given for the page(s) to be excluded/included. These properties are optional and will be ignored when you're not building your app in multi-page mode. Thus all the patterns would be applied to your HTML files.

module.exports = {
    pages: {
        index: {
            entry: "src/App_1/main.js",
            filename: "app_1.html"
        },
        app_2: "src/App_2/main.js",
        app_3: "src/App_3/main.js",
    },
    pluginOptions: {
        htmlReplace: {
            patterns: [
                {
                    match: "foo",
                    replacement: "All of your pages will be affected",
                },
                {
                    match: /<title>.*<\/title>/,
                    replacement: "<title>This is the index page</title>",
                    includes: "index",
                },
                {
                    match: /<title>.*<\/title>/,
                    replacement: "<title>This is the second page</title>",
                    excludes: ["index" , "app_3"],
                },
            ],
        },
    },
};

API

Global

| Name | Type | Default | Description | | :--: | :--: | :--: | --- | | enable | Boolean | true | Enables/disables the plugin. | | patterns | Object | Array<Object> | [] | Defines some patterns and how to replace their corresponding matches. |

Pattern

| Name | Type | Default | Description | | :--: | :--: | :--: | --- | | match | String | RegExp | null | Defines the matches to be replaced. When missing, the pattern will be ignored. | | replacement | String | Function:String | null | Specifies the value with which to replace the matches. When missing, the pattern will be ignored. | | includes | String | Array<String> | null | Includes the pages for which the pattern will be applied to, when deploying your app in multi-page mode. Each entry must be named after the key of a page. | | excludes | String | Array<String> | null | Prevents the pattern to be applied to specific pages in multi-page mode. Each entry must be named after the key of a page. This option will be ignored if includes has already been set. |