How to use the @vue/cli-shared-utils.warn function in @vue/cli-shared-utils

To help you get started, we’ve selected a few @vue/cli-shared-utils 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 adambullmer / vue-cli-plugin-browser-extension / index.js View on Github external
.rule('provide-webextension-polyfill')
      .test(require.resolve('webextension-polyfill', { paths: [appRootPath] }))
      .use('imports')
      .loader('imports-loader')
      .options({ browser: '>undefined' })

    if (isProduction) {
      // Silence warnings of known large files, like images, sourcemaps, and the zip artifact
      webpackConfig.performance.assetFilter((assetFilename) =>
        performanceAssetFilterList.every((filter) => filter(assetFilename))
      )

      if (hasKeyFile) {
        webpackConfig.plugin('copy-signing-key').use(CopyWebpackPlugin, [[{ from: keyFile, to: 'key.pem' }]])
      } else {
        logger.warn('No `key.pem` file detected. This is problematic only if you are publishing an existing extension')
      }
    }

    if (isProduction) {
      webpackConfig.plugin('zip-browser-extension').use(ZipPlugin, [
        {
          path: api.resolve(pluginOptions.artifactsDir || 'artifacts'),
          filename: `${packageJson.name}-v${packageJson.version}-${api.service.mode}.zip`
        }
      ])
    }

    // configure webpack-extension-reloader for automatic reloading of extension when content and background scripts change (not HMR)
    // enabled only when webpack mode === 'development'
    if (!isProduction) {
      webpackConfig.plugin('extension-reloader').use(ExtensionReloader, [{ entries, ...extensionReloaderOptions }])
github nklayman / vue-cli-plugin-electron-builder / generator / index.js View on Github external
module.exports = (api, options = {}) => {
  if (!options.electronBuilder) options.electronBuilder = {}
  const electronVersion = options.electronBuilder.electronVersion
  let pkg = fs.readFileSync(api.resolve('./package.json'), 'utf8')
  pkg = JSON.parse(pkg)
  const usesTS = api.hasPlugin('typescript')
  const hasBackground =
    fs.existsSync(api.resolve(`./src/background.ts`)) ||
    fs.existsSync(api.resolve(`./src/background.js`))

  const devtoolsExtensionsBroken = semver.gte(
    (electronVersion || pkg.devDependencies.electron).replace('^', ''),
    '6.0.0'
  )
  if (devtoolsExtensionsBroken) {
    warn('Devtools extensions are broken in Electron 6.0.0 and greater')
    warn(
      'Vue Devtools have been disabled, see the comments in your background file for more info'
    )
  }
  if (!hasBackground) {
    // If user does not have a background file it should be created
    api.render('./templates/base', {
      // Scheme registration changed in Electron 5.0.0
      newSchemeRegistrationFunction: semver.gte(
        (electronVersion || pkg.devDependencies.electron).replace('^', ''),
        '5.0.0'
      ),
      devtoolsExtensionsBroken
    })
  }
  // Add tests
github nklayman / vue-cli-plugin-electron-builder / generator / index.js View on Github external
if (!options.electronBuilder) options.electronBuilder = {}
  const electronVersion = options.electronBuilder.electronVersion
  let pkg = fs.readFileSync(api.resolve('./package.json'), 'utf8')
  pkg = JSON.parse(pkg)
  const usesTS = api.hasPlugin('typescript')
  const hasBackground =
    fs.existsSync(api.resolve(`./src/background.ts`)) ||
    fs.existsSync(api.resolve(`./src/background.js`))

  const devtoolsExtensionsBroken = semver.gte(
    (electronVersion || pkg.devDependencies.electron).replace('^', ''),
    '6.0.0'
  )
  if (devtoolsExtensionsBroken) {
    warn('Devtools extensions are broken in Electron 6.0.0 and greater')
    warn(
      'Vue Devtools have been disabled, see the comments in your background file for more info'
    )
  }
  if (!hasBackground) {
    // If user does not have a background file it should be created
    api.render('./templates/base', {
      // Scheme registration changed in Electron 5.0.0
      newSchemeRegistrationFunction: semver.gte(
        (electronVersion || pkg.devDependencies.electron).replace('^', ''),
        '5.0.0'
      ),
      devtoolsExtensionsBroken
    })
  }
  // Add tests
  let testFramework
github vuejs / vue-cli / packages / @vue / cli / lib / util / mergeDeps.js View on Github external
// built-in
      res[name] = didGetNewer ? injectSemver(r2, r) : r1
      // if changed, update source
      if (res[name] === r2) {
        sources[name] = generatorId
      }
      // warn incompatible version requirements
      if (
        !forceNewVersion &&
        (
          !semver.validRange(r1semver) ||
          !semver.validRange(r2semver) ||
          !semver.intersects(r1semver, r2semver)
        )
      ) {
        warn(
          `conflicting versions for project dependency "${name}":\n\n` +
          `- ${r1} injected by generator "${sourceGeneratorId}"\n` +
          `- ${r2} injected by generator "${generatorId}"\n\n` +
          `Using ${didGetNewer ? `newer ` : ``}version (${res[name]}), but this may cause build errors.`
        )
      }
    }
  }
  return res
}
github vuejs / vue-cli / packages / @vue / cli-service / lib / commands / build / index.js View on Github external
env: {
            VUE_CLI_MODERN_BUILD: true
          }
        })
      } else {
        // sub-process for modern build
        await build(Object.assign({}, args, {
          modernBuild: true,
          clean: false
        }), api, options)
      }
      delete process.env.VUE_CLI_MODERN_MODE
    } else {
      if (args.modern) {
        const { warn } = require('@vue/cli-shared-utils')
        warn(
          `Modern mode only works with default target (app). ` +
          `For libraries or web components, use the browserslist ` +
          `config to specify target browsers.`
        )
      }
      await build(args, api, options)
    }
    delete process.env.VUE_CLI_BUILD_TARGET
  })
}
github KuangPF / vue-cli-analysis / packages / @vue / cli-service / lib / Service.js View on Github external
pkgConfig = this.pkg.vue
    if (pkgConfig && typeof pkgConfig !== 'object') {
      error(
        `Error loading vue-cli config in ${chalk.bold(`package.json`)}: ` +
        `the "vue" field should be an object.`
      )
      pkgConfig = null
    }

    if (fileConfig) { // 既有 vue.config.js 而且在 package.json 里面又包含了 vue 的配置,将会取 vue.config.js 的配置
      if (pkgConfig) {
        warn(
          `"vue" field in package.json ignored ` +
          `due to presence of ${chalk.bold('vue.config.js')}.`
        )
        warn(
          `You should migrate it into ${chalk.bold('vue.config.js')} ` +
          `and remove it from package.json.`
        )
      }
      resolved = fileConfig
      resolvedFrom = 'vue.config.js'
    } else if (pkgConfig) {
      resolved = pkgConfig
      resolvedFrom = '"vue" field in package.json'
    } else {
      resolved = this.inlineOptions || {}
      resolvedFrom = 'inline options'
    }

    // normalize some options
    ensureSlash(resolved, 'baseUrl')
github vuejs / vue-cli / packages / @vue / cli-service / lib / config / css.js View on Github external
api.chainWebpack(webpackConfig => {
    const getAssetPath = require('../util/getAssetPath')
    const shadowMode = !!process.env.VUE_CLI_CSS_SHADOW_MODE
    const isProd = process.env.NODE_ENV === 'production'

    let sassLoaderVersion
    try {
      sassLoaderVersion = semver.major(require('sass-loader/package.json').version)
    } catch (e) {}
    if (sassLoaderVersion < 8) {
      pauseSpinner()
      warn('A new version of sass-loader is available. Please upgrade for best experience.')
      resumeSpinner()
    }

    const defaultSassLoaderOptions = {}
    try {
      defaultSassLoaderOptions.implementation = require('sass')
      // since sass-loader 8, fibers will be automatically detected and used
      if (sassLoaderVersion < 8) {
        defaultSassLoaderOptions.fiber = require('fibers')
      }
    } catch (e) {}

    const {
      extract = isProd,
      sourceMap = false,
      loaderOptions = {}
github multiplegeorges / vue-cli-plugin-s3-deploy / src / index.js View on Github external
}, (_) => {
    let options = configOptions.pluginOptions.s3Deploy
    let config = new Configuration(options)

    if (!config.options.bucket) {
      error('Bucket name must be specified with `bucket` in vue.config.js!')
    } else {
      if (config.options.pwa && !config.options.pwaFiles) {
        warn('Option pwa is set but no files specified! Defaulting to: service-worker.js')
        config.options.pwaFiles = 'service-worker.js'
      }

      if(process.env['S3D_DEBUG']) console.log(config.options)

      let deployer = new Deployer(config)
      deployer.openConnection()
      deployer.run()
    }
  })
}
github gridsome / gridsome / packages / gridsome-core / lib / PluginAPI.js View on Github external
    this.warn = message => warn(message, plugin.id)
    this.error = message => error(message, plugin.id)
github nklayman / vue-cli-plugin-electron-builder / index.js View on Github external
(args, rawArgs) => {
      warn('This command is deprecated. Please use electron:serve instead.')
      return api.service.run(
        'electron:serve',
        { ...args, _: ['First arg is removed', ...args._] },
        ['First arg is removed', ...rawArgs]
      )
    }
  )