How to use the @create-figma-plugin/common.constants.build function in @create-figma-plugin/common

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
export function createWebpackConfig (entry, isDevelopment) {
  const mode = isDevelopment ? 'development' : 'production'
  return {
    mode,
    entry,
    output: {
      filename: '[name].js',
      path: join(process.cwd(), constants.build.directoryName)
    },
    module: {
      rules: [
        {
          test: /\.js?$/,
          exclude: /node_modules\/(?!@create-figma-plugin)/,
          use: {
            loader: 'babel-loader',
            options: {
              plugins: [
                '@babel/plugin-proposal-object-rest-spread',
                [
                  '@babel/plugin-transform-template-literals',
                  {
                    loose: true
                  }
github yuanqing / create-figma-plugin / packages / build / src / build-manifest.js View on Github external
name: config.name,
    id: config.id,
    api: config.apiVersion
  }
  if (hasBundle(config, 'command') === true) {
    result.main = constants.build.pluginCodeFilePath
  }
  if (hasBundle(config, 'ui') === true) {
    result.ui = constants.build.pluginUiFilePath
  }
  const menu = config.menu
  if (typeof menu !== 'undefined') {
    result.menu = normaliseMenu(menu)
  }
  const string = JSON.stringify(result) + '\n'
  return outputFile(constants.build.manifestFilePath, string)
}
github yuanqing / create-figma-plugin / packages / build / src / build-bundle.js View on Github external
export async function buildBundle (config, isDevelopment) {
  const entry = {}
  const commandEntryFile = await createCommandEntryFile(config)
  if (commandEntryFile !== null) {
    const key = extractBasename(constants.build.pluginCodeFilePath)
    entry[key] = commandEntryFile
  }
  const uiEntryFile = await createUiEntryFile(config)
  if (uiEntryFile !== null) {
    const key = extractBasename(constants.build.pluginUiFilePath)
    entry[key] = uiEntryFile
  }
  let webpackConfig = createWebpackConfig(entry, isDevelopment)
  const customWebpackConfigPath = await findUp(constants.configFileName)
  if (typeof customWebpackConfigPath !== 'undefined') {
    webpackConfig = require(customWebpackConfigPath)(webpackConfig)
  }
  return new Promise(function (resolve, reject) {
    webpack(webpackConfig, async function (error, stats) {
      if (stats.hasErrors() === true) {
        reject(stats.toJson().errors.join('\n'))
        return
      }
      if (error) {
        reject(error)
        return