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

@amazingbv/webpack-theme-json-generator

v1.1.1

Published

An npm package for Webpack for generating your WordPress theme.json file from multiple JSON files.

Downloads

34

Readme

A plugin for Webpack to generate your WordPress theme.json file from multiple files.

Installation

Include the package in your project:

npm install @amazingbv/webpack-theme-json-generator --save-dev

Description

The plugin will generate a theme.json file from multiple files. Given a source directory the plugin will use the 'dot notation' to create the correct theme.json structure.

Usage

Add the plugin to your Webpack config file:

// webpack.config.js
const ThemeJsonGeneratorPlugin = require('@amazingbv/webpack-theme-json-generator').default;

module.exports = {
  // ...
  plugins: [
    new ThemeJsonGenerator({
        sourceDirectory: 'theme-name/theme/',
        destinationFile: 'theme-name/theme.json'
    })
  ]
};

Alternatively, you can use this Webpack plugin in your Laravel Mix configuration. To use this, add the following to your Laravel Mix config:

// webpack.mix.js
const ThemeJsonGeneratorPlugin = require('@amazingbv/webpack-theme-json-generator').default;

mix.webpackConfig({
    plugins: [
        new ThemeJsonGeneratorPlugin({
            sourceDirectory: 'theme-name/theme/',
            destinationFile: 'theme-name/theme.json'
        })
    ]
});

Alternative uses

You can also use this plugin to generate other JSON files. To do this, you can change the sourceFile and filePrefix values. An example of this config could be as follows:

new ThemeJsonGeneratorPlugin({
    sourceFile: 'products.json',
    sourceDirectory: 'sub-dir/products/',
    filePrefix: 'products.',
    destinationFile: 'sub-dir/products.json'
})

Above configuration will scan the sub-dir/products/ directory for all JSON files, taking products.json as the base file, instead of theme.json. The filePrefix value will be used to determine which files to include in the final JSON file. In this case, all files that start with products. will be included in the final products.json file.

File structure

Files in the source directory should be structured like this:

.
├── theme/
│   ├── theme.json
│   ├── theme.settings.json
│   ├── theme.settings.typography.json
│   ├── theme.settings.typography.fontFamilies.json
│   ├── theme.styles.json
│   ├── theme.styles.blocks.core-group.json

Using a - (dash) in a file name will be formatted to a / (slash) in the theme.json file, so core-group will be formatted to core/group.

Ofcourse this is just an example. You can split the theme.json file in any way and in any amount of files you want.

License

MIT