How to use webpack-format-messages - 6 common examples

To help you get started, we’ve selected a few webpack-format-messages 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 GDJiaMi / jm-cli / src / cmds / dll / generateDll.ts View on Github external
compiler.run((err, stats) => {
      if (err) {
        message.error('[DLL] Failed to compile:')
        console.error(err.stack || err)
        // @ts-ignore
        if (err.details) {
          // @ts-ignore
          console.error(err.details)
        }
        rej(err)
        return
      }
      const messages = formatMessages(stats)
      if (messages.errors.length) {
        message.error('[DLL] Failed to compile.\n\n')
        messages.errors.forEach(e => console.log(e))
        rej(new Error('[DLL] Failed to compile'))
        return
      }

      if (messages.warnings.length) {
        message.warn('[DLL] Compiled with warnings.\n\n')
        messages.warnings.forEach(e => console.log(e))
      } else {
        message.success('[DLL] Compiled successfully.')
      }

      // 更新hash
      fs.writeFileSync(paths.appDllHash, key)
github GDJiaMi / jm-cli / src / cmds / analyze.ts View on Github external
compiler.run(async (err, stats) => {
    if (err) {
      spinner.stopAndPersist({ text: 'Failed to compile.', symbol: logSymbols.error })
      console.error(err.stack || err)
      // @ts-ignore
      if (err.details) {
        // @ts-ignore
        console.error(err.details)
      }
      return
    }

    if (stats.hasErrors()) {
      spinner.stopAndPersist({ text: 'Failed to compile.\n\n', symbol: logSymbols.error })
      const messages = formatMessages(stats)
      if (messages.errors.length) {
        messages.errors.forEach(e => console.log(e))
      }
      return
    }

    const port = await choosePort(8888)

    const json = stats.toJson()
    analyzer.start(json, { port })

    await fs.writeJSON(path.join(paths.appDist, 'stat.json'), json)

    spinner.stopAndPersist({ text: 'Extract successfully.', symbol: logSymbols.success })
  })
}
github GDJiaMi / jm-cli / src / cmds / build.ts View on Github external
compiler.run((err, stats) => {
    if (err) {
      spinner.stopAndPersist({ text: 'Failed to compile.', symbol: logSymbols.error })
      console.error(err.stack || err)
      // @ts-ignore
      if (err.details) {
        // @ts-ignore
        console.error(err.details)
      }
      return
    }

    const messages = formatMessages(stats)
    if (messages.errors.length) {
      spinner.stopAndPersist({ text: 'Failed to compile.\n\n', symbol: logSymbols.error })
      messages.errors.forEach(e => console.log(e))
      return
    }

    // copy dll
    if (supportDll) {
      const dllName = path.basename(paths.appDllFile)
      fs.copyFileSync(paths.appDllFile, path.join(paths.appDist, dllName))
    }

    if (messages.warnings.length) {
      spinner.stopAndPersist({ text: 'Compiled with warnings.\n\n', symbol: logSymbols.warn })
      messages.warnings.forEach(e => console.log(e))
    } else {
github GDJiaMi / jm-cli / src / cmds / start.ts View on Github external
compiler!.hooks.done.tap('done', stats => {
    started = true
    spinner.stop()
    firstCompile = false
    const messages = formatMessages(stats)
    if (messages.errors.length) {
      message.error('Failed to compile.\n\n')
      messages.errors.forEach(e => console.log(e))
      return
    }

    if (onCompileSuccess) {
      onCompileSuccess(stats)
    }

    if (messages.warnings.length) {
      message.warn('Compiled with warnings.\n\n')
      messages.warnings.forEach(e => console.log(e))
      return
    }
github sveltejs / sapper / src / core / create_compilers.ts View on Github external
constructor(stats: any) {
		super();

		this.stats = stats;

		const info = stats.toJson();

		const messages = format_messages(stats);

		this.errors = messages.errors.map(munge_webpack_warning_or_error);
		this.warnings = messages.warnings.map(munge_webpack_warning_or_error);

		this.duration = info.time;

		this.chunks = info.assets.map((chunk: { name: string }) => chunk.name);
		this.assets = info.assetsByChunkName;
	}
github sveltejs / sapper / src / core / create_compilers / WebpackResult.ts View on Github external
constructor(stats: any) {
		this.stats = stats;

		const info = stats.toJson();

		const messages = format_messages(stats);

		this.errors = messages.errors.map(munge_warning_or_error);
		this.warnings = messages.warnings.map(munge_warning_or_error);

		this.duration = info.time;

		this.chunks = info.assets.map((chunk: { name: string }) => ({ file: chunk.name }));
		this.assets = info.assetsByChunkName;
	}

webpack-format-messages

Beautiful formatting for Webpack messages; ported from Create React App!

MIT
Latest version published 3 years ago

Package Health Score

50 / 100
Full package analysis

Popular webpack-format-messages functions