0.0.5 • Published 5 years ago

@dschau/gatsby-theme-utils v0.0.5

Weekly downloads
6
License
MIT
Repository
-
Last release
5 years ago

@dschau/gatsby-theme-utils

Install

npm i @dschau/gatsby-theme-utils

Usage

The utility exposes a number of helpful utilities, particularly:

addToWebpackConfig

A utility to add the current theme to webpack so that the theme does not have to be transpiled.

Usage

In gatsby-node.js:

const { addToWebpackConfig } = require('@dschau/gatsby-theme-utils');

const { name } = require('./package.json'); // the theme name

exports.onCreateWebpackConfig = addToWebpackConfig(name);

additionally, the utility exposes a callback that can be used to add any additional webpack configuation, e.g.

const { addToWebpackConfig } = require('@dschau/gatsby-theme-utils');

const { name } = require('./package.json'); // the theme name

exports.onCreateWebpackConfig = addToWebpackConfig(
  name,
  ({ actions, loaders }) => {
    // note: this is just an example; don't add this loader :)
    actions.setWebpackConfig({
      module: {
        rules: [
          {
            test: 'my-css',
            use: [loaders.style(), loaders.css()],
          },
        ],
      },
    });
  }
);