How to use find-cache-dir - 10 common examples

To help you get started, we’ve selected a few find-cache-dir 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 storybookjs / storybook / app / react / src / server / config.js View on Github external
export default function(configType, baseConfig, configDir) {
  const config = baseConfig;

  const babelConfig = loadBabelConfig(configDir);
  config.module.rules[0].query = {
    // This is a feature of `babel-loader` for webpack (not Babel itself).
    // It enables a cache directory for faster-rebuilds
    // `find-cache-dir` will create the cache directory under the node_modules directory.
    cacheDirectory: findCacheDir({ name: 'react-storybook' }),
    ...babelConfig,
  };

  // Check whether a config.js file exists inside the storybook
  // config directory and throw an error if it's not.
  const storybookConfigPath = path.resolve(configDir, 'config.js');
  if (!fs.existsSync(storybookConfigPath)) {
    const err = new Error(`=> Create a storybook config file in "${configDir}/config.js".`);
    throw err;
  }
  config.entry.preview.push(require.resolve(storybookConfigPath));

  // Check whether addons.js file exists inside the storybook.
  // Load the default addons.js file if it's missing.
  // Insert it after polyfills.js, but before client/manager.
  const storybookDefaultAddonsPath = path.resolve(__dirname, 'addons.js');
github storybookjs / storybook / lib / core / src / server / core-preset-babel-cache.js View on Github external
export function babel(babelConfig) {
  return {
    // This is a feature of `babel-loader` for webpack (not Babel itself).
    // It enables a cache directory for faster-rebuilds
    // `find-cache-dir` will create the cache directory under the node_modules directory.
    cacheDirectory: findCacheDir({ name: 'react-storybook' }),
    ...babelConfig,
  };
}
github CJY0208 / webpack-multiple-pages / build / utils / autodll-webpack-plugin / src / paths.js View on Github external
import path from 'path'
import findCacheDir from 'find-cache-dir'

export const cacheDir = findCacheDir({ name: 'autodll-webpack-plugin' })

export const getManifestPath = hash => bundleName =>
  path.resolve(cacheDir, hash, `${bundleName}.manifest.json`)

export const getInjectPath = ({ publicPath, pluginPath, filename }) => {
  let injectPublicPath = publicPath
  let injectRestPath = path.posix.join(pluginPath, filename)
  // Ensure that injectPublicPath and injectRestPath can be safely concatinated
  if (injectPublicPath && !injectPublicPath.endsWith('/')) {
    injectPublicPath += '/'
  }
  if (injectRestPath.startsWith('/')) {
    injectRestPath = injectRestPath.substr(1)
  }
  return injectPublicPath + injectRestPath
}
github reworkjs / reworkjs / src / shared / webpack / WebpackBase.js View on Github external
getBabelConfig() {
    const config = frameworkBabelRc;
    config.plugins = config.plugins || [];

    if (this.isDev) {
      config.presets.push('react-hmre');
    }

    // This is a feature of `babel-loader` for webpack (not Babel itself).
    // It enables caching results in ./node_modules/.cache/react-scripts/
    // directory for faster rebuilds. We use findCacheDir() because of:
    // https://github.com/facebookincubator/create-react-app/issues/483
    config.cacheDirectory = findCacheDir({
      name: frameworkMetadata.name,
    });

    return config;
  }
github storybookjs / storybook / lib / core / src / server / manager / manager-webpack.config.js View on Github external
import CaseSensitivePathsPlugin from 'case-sensitive-paths-webpack-plugin';
import CoreJSUpgradeWebpackPlugin from 'corejs-upgrade-webpack-plugin';

import themingPaths from '@storybook/theming/paths';
import uiPaths from '@storybook/ui/paths';

import findCacheDir from 'find-cache-dir';

import { version } from '../../../package.json';
import { getManagerHeadHtml } from '../utils/template';
import { loadEnv } from '../config/utils';
import babelLoader from '../common/babel-loader';

const coreDirName = path.dirname(require.resolve('@storybook/core/package.json'));
const context = path.join(coreDirName, '../../node_modules');
const cacheDir = findCacheDir({ name: 'storybook' });

export default ({
  configDir,
  configType,
  docsMode,
  entries,
  dll,
  outputDir,
  cache,
  babelOptions,
  previewUrl,
  versionCheck,
}) => {
  const { raw, stringified } = loadEnv();
  const isProd = configType === 'PRODUCTION';
github phenomic / phenomic / src / _utils / cache / webpack.js View on Github external
export default (config: PhenomicOldConfig): Array => {
  if (!config.cache) {
    return []
  }

  const cacheDir = findCacheDir({
    name: "phenomic/webpack-hard-source-cache/[confighash]/",
  })

  return [
    new HardSourceWebpackPlugin({
      cacheDirectory: join(cacheDir),
      recordsPath: join(cacheDir, "records.json"),
      configHash: (config) => (new ObjectHash()).hash(config),
      environmentPaths: {
        root: config.cwd,
        files: [
          "package.json",
          "webpack.config.js",
        ],
      },
    }),
github prisma / photonjs / packages / fetch-engine / src / util.ts View on Github external
export async function getRootCacheDir(): Promise {
  if (os.platform() === 'win32') {
    const cacheDir = await findCacheDir({ name: 'prisma', create: true })
    if (cacheDir) {
      return cacheDir
    }
    if (process.env.APPDATA) {
      return path.join(process.env.APPDATA, 'Prisma')
    }
  }
  return path.join(os.homedir(), '.cache/prisma')
}
github admob-plus / admob-plus / packages / cordova / rollup.config.js View on Github external
export default {
  external: ['cordova'],
  input: './ts/admob.ts',
  output: {
    file: 'www/admob.js',
    format: 'cjs',
    sourcemap: false,
    exports: 'default',
  },
  plugins: [
    resolve({
      mainFields: ['module', 'main', 'jsnext:main'],
      browser: true,
    }),
    typescript({
      cacheRoot: findCacheDir({ name: 'rts2' }),
      tsconfigOverride: {
        compilerOptions: {
          module: 'es2015',
        },
      },
    }),
    commonjs(),
  ],
}
github wxajs / wxa / packages / wxa-compiler-babel / src / fs-cache.js View on Github external
export default function(params) {
    let {directory} = params;
    if (typeof directory !== 'string') {
        directory = findCacheDir({name: '@wxa/compiler-babel'}) || os.tmpdir();
    }
    return handleCache(directory, params);
}
github phenomic / phenomic / src / _utils / cache / webpack.js View on Github external
return []
  }

  if (webpackVersion() === 2) {
    if (!warned) {
      log(
        "Phenomic 'cache' option is not compatible yet with webpack@2 so the " +
        "option is ignored. \n" +
        "Please track https://github.com/MoOx/phenomic/issues/777"
      )
      warned = true
    }
    return []
  }

  const cacheDir = findCacheDir({
    name: "phenomic/webpack-hard-source-cache/[confighash]/",
  })

  return [
    new HardSourceWebpackPlugin({
      cacheDirectory: join(cacheDir),
      recordsPath: join(cacheDir, "records.json"),
      configHash: (config) => (new ObjectHash()).hash(config),
      environmentPaths: {
        root: config.cwd,
        files: [
          "package.json",
          "webpack.config.babel.js",
        ],
      },
    }),

find-cache-dir

Finds the common standard cache directory

MIT
Latest version published 1 year ago

Package Health Score

73 / 100
Full package analysis

Popular find-cache-dir functions