How to use the webpack.ProgressPlugin function in webpack

To help you get started, we’ve selected a few webpack 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 zubairghori / Ultimate_todo_list / node_modules / webpack-dev-server / bin / webpack-dev-server.js View on Github external
function startDevServer(webpackOptions, options) {
  addDevServerEntrypoints(webpackOptions, options);

  let compiler;
  try {
    compiler = webpack(webpackOptions);
  } catch (e) {
    if (e instanceof webpack.WebpackOptionsValidationError) {
      console.error(colorError(options.stats.colors, e.message));
      process.exit(1); // eslint-disable-line
    }
    throw e;
  }

  if (options.progress) {
    compiler.apply(new webpack.ProgressPlugin({
      profile: argv.profile
    }));
  }

  const suffix = (options.inline !== false || options.lazy === true ? '/' : '/webpack-dev-server/');

  let server;
  try {
    server = new Server(compiler, options);
  } catch (e) {
    const OptionsValidationError = require('../lib/OptionsValidationError');
    if (e instanceof OptionsValidationError) {
      console.error(colorError(options.stats.colors, e.message));
          process.exit(1); // eslint-disable-line
    }
    throw e;
github js-joda / js-joda / utils / build_package.js View on Github external
webpackConfig = Object.keys(argv.packages).map((key) => {
        const locales = argv.packages[key];
        const output = path.resolve(path.resolve(process.cwd(), argv.output, key));
        return createWebpackConfig(locales, output);
    });
}

if (webpackConfig) {
    RegExp.prototype.toJSON = RegExp.prototype.toString;
    /* eslint-disable no-console */
    if (argv.debug) {
        console.log(JSON.stringify(webpackConfig, null, 4));
    }
    const webpackCompiler = webpack(webpackConfig);

    webpackCompiler.apply(new webpack.ProgressPlugin());

    webpackCompiler.run((err, stats) => {
        if (err) {
            console.error(err.stack || err);
            if (err.details) {
                console.error(err.details);
            }
            return;
        }

        const info = stats.toJson();

        if (stats.hasErrors()) {
            console.error(info.errors);
        }
github apache / incubator-weex-cli / packages / @weex / plugins / compile / src / WeexBuilder.ts View on Github external
if (this.options.filename) {
      outputFilename = this.options.filename
    } else {
      outputFilename = '[name].js'
    }
    // Call like: ./bin/weex-builder.js test/index.vue dest/test.js
    // Need to rename the filename of
    if (destExt && this.dest[this.dest.length - 1] !== '/' && sourceExt) {
      outputPath = path.dirname(this.dest)
      outputFilename = path.basename(this.dest)
    } else {
      outputPath = this.dest
    }

    if (this.options.onProgress) {
      plugins.push(new webpack.ProgressPlugin(this.options.onProgress))
    }
    const hasVueRouter = (content: string) => {
      return /(\.\/)?router/.test(content)
    }

    const getEntryFileContent = (source, routerpath) => {
      const hasPluginInstalled = fse.existsSync(path.resolve(this.pluginFileName))
      let dependence = `import Vue from 'vue'\n`
      dependence += `import weex from 'weex-vue-render'\n`
      let relativePluginPath = path.resolve(this.pluginConfigFileName)
      let entryContents = fse.readFileSync(source).toString()
      let contents = ''
      entryContents = dependence + entryContents
      entryContents = entryContents.replace(/\/\* weex initialized/, match => `weex.init(Vue)\n${match}`)
      if (this.isWin) {
        relativePluginPath = relativePluginPath.replace(/\\/g, '\\\\')
github flaviuse / mern-authentication / client / node_modules / webpack-dev-server / bin / webpack-dev-server.js View on Github external
let compiler;

  try {
    compiler = webpack(config);
  } catch (err) {
    if (err instanceof webpack.WebpackOptionsValidationError) {
      log.error(colors.error(options.stats.colors, err.message));
      // eslint-disable-next-line no-process-exit
      process.exit(1);
    }

    throw err;
  }

  if (options.progress) {
    new webpack.ProgressPlugin({
      profile: argv.profile,
    }).apply(compiler);
  }

  const suffix =
    options.inline !== false || options.lazy === true
      ? '/'
      : '/webpack-dev-server/';

  try {
    server = new Server(compiler, options, log);
  } catch (err) {
    if (err.name === 'ValidationError') {
      log.error(colors.error(options.stats.colors, err.message));
      // eslint-disable-next-line no-process-exit
      process.exit(1);
github makuga01 / dnsFookup / FE / node_modules / webpack-dev-server / lib / Server.js View on Github external
setupProgressPlugin() {
    // for CLI output
    new webpack.ProgressPlugin({
      profile: !!this.options.profile,
    }).apply(this.compiler);

    // for browser console output
    new webpack.ProgressPlugin((percent, msg, addInfo) => {
      percent = Math.floor(percent * 100);

      if (percent === 100) {
        msg = 'Compilation completed';
      }

      if (addInfo) {
        msg = `${msg} (${addInfo})`;
      }

      this.sockWrite(this.sockets, 'progress-update', { percent, msg });
    }).apply(this.compiler);
  }
github DragonsInn / BIRD3 / util / webpack.config.js View on Github external
"target="+app,
    "sourceMap"
].join("&");
// Configure SASS
var sassq = [
    "includePaths[]="+path.join(
        config.base, "bower_components",
        "bootstrap-sass/assets/stylesheets"
    ),
    "includePaths[]="+path.join(config.base, "bower_components"),
    "includePaths[]="+path.join(config.base, "node_modules"),
    "includePaths[]="+path.join(config.base, "themes"),
    "sourceMap"
].join("&");
// Progress output
var progress = new webpack.ProgressPlugin(function(p, msg){
    if(p===0) msg = "Starting compilation...";
    if(p===1) msg = "Done!";
    BIRD3.log.update("WebPack => [%s%%]: %s", p.toFixed(2)*100, msg);
});
// Try to press down further
var dedupe = new webpack.optimize.DedupePlugin();

// Banner
var bannerPlugin = new webpack.BannerPlugin((function(){
    return require("ejs").render(
        fs.readFileSync(path.join(__dirname, "banner.ejs"), "utf8"),
        {
            version: config.version
        },{
            filename: path.join(__dirname, "banner.ejs"),
            rmWhitespace: false
github electrode-io / electrode / packages / electrode-archetype-react-app-dev / lib / dev-admin / middleware.js View on Github external
Object.keys(config.entry).forEach(k => {
        config.entry[k] = hmrClient.concat(config.entry[k]);
      });
    } else {
      config.entry = hmrClient.concat(config.entry);
    }

    config.plugins = [
      new webpack.HotModuleReplacementPlugin(),
      new webpack.NoEmitOnErrorsPlugin()
    ].concat(config.plugins);

    const compiler = webpack(config);

    if (options.progress !== false) {
      compiler.apply(new webpack.ProgressPlugin({ profile: options.progressProfile }));
    }

    const webpackDevOptions = _.merge(
      {
        // https: false,
        // disableHostCheck: true,
        headers: {
          "Access-Control-Allow-Origin": "*"
        },
        // port: archetype.webpack.devPort,
        // host: archetype.webpack.devHostname,
        quiet: false,
        lazy: false,
        watchOptions: {
          aggregateTimeout: 2000,
          poll: false
github callstack / haul / packages / haul-core-legacy / src / compiler / worker / runWebpackCompiler.js View on Github external
}

      continue;
    }

    let config = projectConfig.webpackConfigs[bundleName];

    /**
     * Let's add ProgressPlugin, but let's be sure that we don't mutate the user's config
     */
    let lastLocalProgress = 0;
    config = {
      ...config,
      plugins: [
        ...config.plugins,
        new webpack.ProgressPlugin(localProgress => {
          if (lastLocalProgress !== localProgress) {
            totalProgress = (bundlesBuilt + localProgress) / bundles.length;
            if (localProgress === 1) {
              bundlesBuilt++;
            }
            emitter.emit(Events.BUILD_PROGRESS, { progress: totalProgress });
            lastLocalProgress = localProgress;
          }
        }),
      ],
    };

    if (projectConfig.bundles[bundleName].dll) {
      await new Promise((resolve, reject) =>
        webpack(config).run(err => {
          if (err) {