How to use the happypack.ThreadPool function in happypack

To help you get started, we’ve selected a few happypack 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 taikongfeizhu / webpack-dll-demo / webpack.config.js View on Github external
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HappyPack = require('happypack');
const webpackServerConfig = require('./server/server.config');
const lib = require('./config/lib.dependencies');

const HappyThreadPool = HappyPack.ThreadPool({ size: 6 });

// 判断当前运行环境是开发模式还是生产模式
const nodeEnv = process.env.NODE_ENV || 'development';
const __DEV__ = nodeEnv !== 'production';
console.log('当前运行环境:', __DEV__ ? 'development' : 'production');

// 是否使用preact
const __PREACT__ = false;

// 区别path和 publicPath的作用
// path 用来存放打包后文件的输出目录
// publicPath 用来定义静态资源的引用地址

const externals = {
  axios: 'axios',
  react: 'React',
github imwtr / webpack-project-config-reference / public / webpack / webpack.config.common.js View on Github external
StyleLintPlugin = require('stylelint-webpack-plugin'),
    TimeFixPlugin = require('time-fix-plugin'),
    BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin,
    UglifyJsPlugin = require('uglifyjs-webpack-plugin'),

    configs = require('./webpack.config.js'),

    // 是否生产环境
    isProduction = process.env.NODE_ENV === 'production',

    // 并行执行loader
    HappyPack = require('happypack'),

    os = require('os'),

    happyThreadPool = HappyPack.ThreadPool({
        size: os.cpus().length
    }),

    processEntity = `${configs.versionControl || 'branch'}--${configs.name || 'anonymous'}--[${process.env.NODE_ENV}]`,

    // 当前目录相对于JS输出模块的路径,因大部分资源的生成路径相对于JS输出模块路径
    cwdRalativeOutputPath = path.relative(path.resolve(__dirname, '../', configs.outputPath), __dirname);

require('node-bash-title')(processEntity);

console.log(processEntity, '\n');

// failOnError使用起来不方便
configs.lint.css.failOnError = false;
configs.lint.js.failOnError = false;
github alibaba-fusion / materials / scaffolds / next-single-page-a11y / webpack.config.js View on Github external
const webpack = require('webpack');
const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const SimpleProgressPlugin = require('webpack-simple-progress-plugin');
const ThemePlugin = require('@alifd/next-theme-webpack-plugin');
const os = require('os');
const HappyPack = require('happypack');

HappyPack.SERIALIZABLE_OPTIONS = HappyPack.SERIALIZABLE_OPTIONS.concat([
  'postcss',
]);

const happyThreadPool = HappyPack.ThreadPool({
  size: os.cpus().length,
});
const DEV = process.env.DEV;
const LIVELOAD = process.env.LIVELOAD;
const cwd = process.cwd();

const entry = {};

// 获取 package.json 中的主题配置文件
let theme = '';
try {
  const pkg = require('./package.json');
  if (pkg && pkg.buildConfig && pkg.buildConfig.theme) {
    theme = pkg.buildConfig.theme;
  }
} catch (e) {
github alibaba-fusion / materials / react-materials / scaffolds / next-single-page / webpack.config.js View on Github external
const webpack = require('webpack');
const path = require('path');
const globby = require('globby');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCssAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const SimpleProgressPlugin = require('webpack-simple-progress-plugin');
const ThemePlugin = require('@alifd/next-theme-webpack-plugin');
const os = require('os');
const HappyPack = require('happypack');
const colors = require('colors');

const happyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length });
const DEV = process.env.DEV;
const LIVELOAD = process.env.LIVELOAD;
const SINGLE_PAGE = process.env.SINGLE_PAGE;
const cwd = process.cwd();

const entry = {};

// 获取 package.json 中的主题配置文件
let theme = '';
try {
  const pkg = require('./package.json');
  if (pkg && pkg.buildConfig && pkg.buildConfig.theme) {
    theme = pkg.buildConfig.theme;
  } else {
    const fieConfig = require('./fie.config.js');
    if (fieConfig && fieConfig.toolkitConfig && fieConfig.toolkitConfig.theme) {
github Coding / WebIDE-Frontend / webpack_configs / common.config.js View on Github external
const path = require('path')
const webpack = require('webpack')
const str = JSON.stringify
const { DefinePlugin } = webpack
const WebpackBar = require('webpackbar')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const GitRevisionPlugin = require('git-revision-webpack-plugin')
const gitRevisionPlugin = new GitRevisionPlugin()
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')
const initMonacoPluginConfig = require('./monaco-plugin-config/initialOptions')
const HappyPack = require('happypack')
const os = require('os')
const execSync = require('child_process').execSync

const happyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length })
const PROJECT_ROOT = path.resolve(__dirname, '..')
// const ICO_PATH = path.join(PROJECT_ROOT, 'static/favicon.ico')
// const ICO_PATH = '//studio-res.coding.net/StudioWebResource/Images/favicon.ico'

module.exports = function(options = {}) {
  const {
    mainEntryHtmlName = 'workspace.html',
    dashboardEntryHtmlName = 'dashboard.html',
    accountEntryHtmlName = 'account.html',
    loginEntryHtmlName = 'login.html',
    introEntryHtmlName = 'intro.html',
    changelogEntryHtmlName = 'changelog.html',
    maintainEntryHtmlName = 'maintain.html',
    workspacesEntryHtmlName = 'index.html',
    staticDir = 'rs',
    filename = '[name].[hash].js',
github ueno-llc / starter-kit-historical / webpack / dev.js View on Github external
const path = require('path');
const webpack = require('webpack');
const bs = require('browser-sync').create();
const proxyMiddleware = require('http-proxy-middleware');
const webpackDevMiddleware = require('webpack-dev-middleware');
const webpackHotMiddleware = require('webpack-hot-middleware');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const HappyPack = require('happypack');
const color = require('cli-color');
const debug = require('../src/utils/debug');
const clientConfig = require('./client');
const serverConfig = require('./server');

const domain = [color.magentaBright('webpack'), '::', color.redBright('server')].join('');
const domainClient = [color.magentaBright('webpack'), '::', color.yellow('client')].join('');
const threadPool = HappyPack.ThreadPool({ size: 8 }); // eslint-disable-line

// Get ports
const port = (parseInt(process.env.PORT, 10) || 3000) - 1;
const proxyPort = port + 1;
const useHappyPack = process.env.HAPPY !== '0';

// Logging
const log = (...args) => debug(domain, ...args);
const logClient = (...args) => debug(domainClient, ...args);

// Use happy or not
if (useHappyPack) {

  // Loaders that we should happypackivide
  const samples = ['.js', '.css', '.scss', '.json'];
github mojisrc / fashop-admin / config / webpack.config.pro.js View on Github external
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');

const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const OptimizeCSSAssetsPlugin = require("optimize-css-assets-webpack-plugin");

const paths = require('./paths');
const getClientEnvironment = require('./env');
const { getPagesFileEntry } = require('./fileReady');
const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin
const publicPath = paths.servedPath;



var HappyPack = require('happypack');
var happyThreadPool = HappyPack.ThreadPool({ size: 5 });


const shouldUseRelativeAssetPaths = publicPath === './';
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
// `publicUrl` is just like `publicPath`, but we will provide it to our app
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
const publicUrl = publicPath.slice(0, -1);
// Get environment variables to inject into our app.
const env = getClientEnvironment(publicUrl);

// Assert this just to be safe.
// Development builds of React are slow and not intended for production.
if (env.stringified['process.env'].NODE_ENV !== '"production"') {
    throw new Error('Production builds must have NODE_ENV=production.');
}
github youzan / zent / site / webpack / happypack-thread-pool.js View on Github external
// We have multiple happypack plugins, its' better to use one shared thread pool
const HappyPack = require('happypack');
const os = require('os');

const happyThreadPool = HappyPack.ThreadPool({ size: os.cpus().length - 1 });

module.exports = happyThreadPool;
github dwqs / vue-startup / template / build / happypack.js View on Github external
const HappyPack = require('happypack')
const happyThreadPool = HappyPack.ThreadPool({ size: 3 })

module.exports = function (opts) {
  return {
    id: opts.id,
    threadPool: happyThreadPool,
    loaders: opts.loaders
  }
}
github geowarin / tarec / lib / webpack / webpack.dev.config.js View on Github external
function makeHappy(args, context, loaders) {
  if (!context.userConfig.happypack.enabled && !args.happy) {
    return [];
  }
  const happyThreadPool = HappyPack.ThreadPool({size: context.userConfig.happypack.cpus});
  return loaders
    .filter(l => l.happy)
    .map(l => new HappyPack({
      id: l.happy.id,
      threadPool: happyThreadPool,
      tempDir: path.join(context.projectDir, '.tarec/happypack'),
      cache: context.userConfig.happypack.cache
    }))
}

happypack

webpack speed booster, makes you happy!

MIT
Latest version published 6 years ago

Package Health Score

50 / 100
Full package analysis

Popular happypack functions