How to use @create-figma-plugin/common - 10 common examples

To help you get started, we’ve selected a few @create-figma-plugin/common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github yuanqing / create-figma-plugin / packages / build / src / watch.js View on Github external
import chokidar from 'chokidar'
import { constants, log } from '@create-figma-plugin/common'
import { build } from './build'

const ignoreRegex = new RegExp(
  [
    '(^|\\/)', // beginning of string or '/'
    '\\.', // '.'
    '[^.]+', // one or more characters that isn't '.'
    `|${constants.build.directoryName}`,
    `|${constants.build.manifestFilePath}`,
    '|node_modules'
  ].join('')
)

export function watch () {
  const watcher = chokidar.watch('.', {
    ignored: function (path) {
      return ignoreRegex.test(path)
    }
  })
  async function run () {
    await build(true, false)
    log.info('Watching...')
  }
  watcher.on('ready', run)
  watcher.on('change', async function (file) {
github yuanqing / create-figma-plugin / packages / build / src / watch.js View on Github external
import chokidar from 'chokidar'
import { constants, log } from '@create-figma-plugin/common'
import { build } from './build'

const ignoreRegex = new RegExp(
  [
    '(^|\\/)', // beginning of string or '/'
    '\\.', // '.'
    '[^.]+', // one or more characters that isn't '.'
    `|${constants.build.directoryName}`,
    `|${constants.build.manifestFilePath}`,
    '|node_modules'
  ].join('')
)

export function watch () {
  const watcher = chokidar.watch('.', {
    ignored: function (path) {
      return ignoreRegex.test(path)
    }
  })
  async function run () {
    await build(true, false)
    log.info('Watching...')
  }
  watcher.on('ready', run)
github yuanqing / create-figma-plugin / packages / build / src / create-webpack-config.js View on Github external
loader: 'css-loader',
              options: {
                importLoaders: 1,
                modules: true
              }
            },
            {
              loader: 'sass-loader'
            }
          ]
        }
      ]
    },
    resolve: {
      modules: [
        join(process.cwd(), constants.src.directory),
        join(process.cwd(), 'node_modules'),
        resolve(process.cwd(), '..', '..', 'node_modules'), // Lerna monorepo
        process.cwd(),
        'node_modules'
      ],
      extensions: ['.js', '.json']
    },
    devtool: isDevelopment ? 'inline-cheap-module-source-map' : 'none',
    stats: 'errors-only',
    plugins: [
      new webpack.EnvironmentPlugin({
        NODE_ENV: mode
      })
    ],
    optimization: {
      minimizer: [
github yuanqing / create-figma-plugin / packages / build / src / build.js View on Github external
export async function build (isDevelopment, exitOnError) {
  log.info('Building plugin...')
  const config = await readConfig()
  try {
    await buildBundle(config, isDevelopment)
    await buildManifest(config)
  } catch (error) {
    log.error(error)
    if (exitOnError === true) {
      process.exit(1)
    }
    return
  }
  log.success('Done')
}
github yuanqing / create-figma-plugin / packages / build / src / build.js View on Github external
export async function build (isDevelopment, exitOnError) {
  log.info('Building plugin...')
  const config = await readConfig()
  try {
    await buildBundle(config, isDevelopment)
    await buildManifest(config)
  } catch (error) {
    log.error(error)
    if (exitOnError === true) {
      process.exit(1)
    }
    return
  }
  log.success('Done')
}
github yuanqing / create-figma-plugin / packages / build / src / build.js View on Github external
export async function build (isDevelopment, exitOnError) {
  log.info('Building plugin...')
  const config = await readConfig()
  try {
    await buildBundle(config, isDevelopment)
    await buildManifest(config)
  } catch (error) {
    log.error(error)
    if (exitOnError === true) {
      process.exit(1)
    }
    return
  }
  log.success('Done')
}
github yuanqing / create-figma-plugin / packages / build / src / build.js View on Github external
export async function build (isDevelopment, exitOnError) {
  log.info('Building plugin...')
  const config = await readConfig()
  try {
    await buildBundle(config, isDevelopment)
    await buildManifest(config)
  } catch (error) {
    log.error(error)
    if (exitOnError === true) {
      process.exit(1)
    }
    return
  }
  log.success('Done')
}
github yuanqing / create-figma-plugin / packages / create-figma-plugin / src / create-figma-plugin.js View on Github external
export async function createFigmaPlugin (options, useDefault) {
  if (typeof options.name !== 'undefined') {
    await throwIfDirectoryExists(join(process.cwd(), options.name))
  }
  log.info('Scaffolding a new plugin...')
  const config = useDefault
    ? createDefaultConfig(options)
    : await promptForUserInput(options)
  const pluginDirectoryPath = join(process.cwd(), config.name)
  await throwIfDirectoryExists(pluginDirectoryPath)
  log.info('Cloning template...')
  await cloneFromTemplate(pluginDirectoryPath, config.template)
  await interpolateValuesIntoFiles(pluginDirectoryPath, config)
  log.info('Installing dependencies...')
  await installDependencies(pluginDirectoryPath)
  log.success('Done')
}
github yuanqing / create-figma-plugin / packages / build / src / watch.js View on Github external
async function run () {
    await build(true, false)
    log.info('Watching...')
  }
  watcher.on('ready', run)
github yuanqing / create-figma-plugin / packages / build / src / watch.js View on Github external
watcher.on('change', async function (file) {
    log.info(`Changed: ${file}`)
    await run()
  })
}