roots / palette-webpack-plugin

Generate a JSON file containing your color palette from existing Sass maps and/or Tailwind.
MIT License
46 stars 7 forks source link

Add Bud support #21

Closed retlehs closed 2 years ago

davideapvd commented 2 years ago

for reference, I've integrated this plugin with bud inside sage with this config inside bud.config.js, specifically I've added the import and the .use line. But how do I specify to use the public/ directory instead of dist if using https://github.com/Log1x/poet ?

/**
 * @typedef {import('@roots/bud').Bud} bud
 *
 * @param {bud} app
 */
const PalettePlugin = require('palette-webpack-plugin');

module.exports = async (app) => {
  app
    /**
     * Application entrypoints
     *
     * Paths are relative to your resources directory
     */
    .entry({
      app: ['@scripts/app', '@styles/app'],
      editor: ['@scripts/editor', '@styles/editor'],
    })

    /**
     * These files should be processed as part of the build
     * even if they are not explicitly imported in application assets.
     */
    .assets('images')

    /**
     * These files will trigger a full page reload
     * when modified.
     */
    .watch('resources/views/**/*', 'app/**/*')

    .use({
      name: 'palette-webpack-plugin',
      make: () => new PalettePlugin({
        output: 'palette.json',
        blacklist: ['transparent', 'inherit'],
        priority: 'tailwind',
        pretty: false,
        tailwind: {
          config: './tailwind.config.js',
          shades: false,
          path: 'colors',
        },
        sass: {
          path: 'resources/assets/styles/config',
          files: ['variables.scss'],
          variables: ['colors'],
        },
      })
    })
    /**
     * Target URL to be proxied by the dev server.
     *
     * This should be the URL you use to visit your local development server.
     */
    .proxy('https://www.example.loc')

    /**
     * Development URL to be used in the browser.
     */
    .serve('https://www.example.loc/_dev');

};
Log1x commented 2 years ago

Thanks for sharing an example of your integration.

Poet should already be looking at the public directory (it calls Roots\asset()).

Feel free to open an issue on Poet to discuss further if that doesn't happen to be working.

davideapvd commented 2 years ago

Thank you @Log1x for the confirmation and fast answer

retlehs commented 2 years ago

https://github.com/roots/sage/pull/2999

https://roots.io/automatically-generating-theme-json-from-tailwind-config/