How to use postcss-url - 10 common examples

To help you get started, we’ve selected a few postcss-url 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 mockingbot / ibot / scripts / rollup-options.js View on Github external
url: (...args) => { // TODO: HACK: postcss-url will return asset-url relative to process.cwd(), so calc the relative asset-url again
                // console.log('HACK:', args)
                const remappedUrl = postcssUrlCopy(...args)
                // console.log('HACK:', { remappedUrl, hackedUrl: remappedUrl && normalize(relative(outputRoot, remappedUrl)) })
                return remappedUrl && normalize(relative(outputRoot, remappedUrl))
              },
            })
github alfa-laboratory / arui-feather / __tests__ / tools.js View on Github external
export const processPostCss = stylePath =>
    postcss(postcssConfig, postcssUrl({ url: 'inline' })).process(fs.readFileSync(stylePath, 'utf-8'), {
        from: stylePath
    });
github remaxjs / remax / packages / remax-cli / src / build / plugins / postcssUrl.ts View on Github external
});
    });

    if (/^\.{1,2}\/|^\w+\//.test(asset.url)) {
      return winPath(
        `/${path.relative(
          path.resolve(options.cwd, options.rootDir),
          asset.absolutePath
        )}`
      );
    }

    return asset.url;
  }

  return purl({
    ...(options.postcss?.url ?? {}),
    url: options.postcss?.url?.inline ? 'inline' : copy,
    maxSize: options.postcss?.url?.maxSize ?? 8,
    fallback: copy,
    basePath: path.resolve(options.cwd, options.rootDir),
    assetsPath: path.resolve(options.cwd, options.output),
  });
}
github bluedaniel / Kakapo-app / tools / postcss.plugins.js View on Github external
export default function(URL) {
  const pluginArr = [lost(), postcssNested(), postcssCssnext()];
  return URL
    ? pluginArr.concat(
        postcssUrl({
          url: url => url.replace(/^\/+/, '')
        })
      )
    : pluginArr;
}
github tinajs / mina-webpack / packages / mina-loader / src / loaders / wxss-url.ts View on Github external
const wxssUrlLoader: webpack.loader.Loader = function wxssUrlLoader(source) {
  const done = this.async()

  const file = this.resourcePath

  const options = {
    from: file,
  }

  const plugins = [postcssUrl({ url: 'inline' })]

  postcss(plugins)
    .process(source, options)
    .then(({ css }) => {
      if (done) {
        done(null, css)
      }
    })
    .catch((error: Error) => done && done(error))
}
github GoogleChromeLabs / proxx / rollup.config.js View on Github external
{
        resolveFileUrl({ fileName }) {
          return JSON.stringify("/" + fileName);
        }
      },
      !prerender && cssModuleTypes("src"),
      postcss({
        minimize: true,
        modules: {
          generateScopedName: "[hash:base64:5]"
        },
        namedExports(name) {
          return name.replace(/-\w/g, val => val.slice(1).toUpperCase());
        },
        plugins: [
          postCSSUrl({
            url: "inline"
          })
        ]
      }),
      constsPlugin({
        version: pkg.version,
        nebulaSafeDark: nebulaColor,
        prerender
      }),
      glsl({ minify: !prerender }),
      ejsAssetPlugin("./src/manifest.ejs", "manifest.json", {
        data: {
          nebulaSafeDark: nebulaHex
        }
      }),
      assetPlugin({
github logux / logux.io / scripts / steps / repack-styles.js View on Github external
async function repackStyles (assets) {
  let collected = []
  let fileCollector = postcssUrl({
    url ({ url }, dir, ops, decl) {
      let media = decl.parent.parent
      let rule = decl.parent
      if (media && media.name === 'media') {
        if (!rule.selector.includes('html.is-dark')) {
          collected.push([media.params, url])
        }
      } else {
        collected.push([undefined, url])
      }
      return url
    }
  })
  let processor = postcss([fileCollector, combineMedia])
  await Promise.all(assets.get(/\.css$/).map(async file => {
    let css = await fs.readFile(file)
github yohangz / ornamentum / gulpfile.babel.js View on Github external
const postProcessCss = css => {
    postcss(processors)
      .use(url({
        url: 'inline',
        basePath: path.resolve(__dirname, 'src/library')
      }))
      .process(css, {
        from: undefined
      })
      .then(result => {
        result.warnings().forEach(function (warn) {
          log.warn(warn.toString());
        });
        styleFile = result.css;
        callback(null, styleFile);
      });
  };
github elastic / kibana / src / legacy / server / sass / build.js View on Github external
outFile: this.targetPath,
      sourceMap: this.sourceMap,
      outputStyle: this.outputStyle,
      sourceMapEmbed: this.sourceMap,
      includePaths: [
        resolve(__dirname, '../../../../node_modules'),
      ],
      importer: this.theme === 'dark' ? DARK_THEME_IMPORTER : undefined
    });

    const processor = postcss([ autoprefixer ]);

    const urlAssets = [];

    if (this.urlImports) {
      processor.use(postcssUrl({
        url: (request) => {
          if (!request.pathname) {
            return request.url;
          }

          const asset = makeAsset(request, (
            request.pathname.startsWith('ui/assets')
              ? {
                path: resolve(UI_ASSETS_DIR, relative('ui/assets', request.pathname)),
                root: UI_ASSETS_DIR,
                boundry: UI_ASSETS_DIR,
                urlRoot: `ui/`,
              }
              : {
                path: resolve(this.sourceDir, request.pathname),
                root: this.sourceDir,
github foxhound87 / rfx-stack / config / postcss.js View on Github external
export default bundler => [
  postcssImport({ addDependencyTo: bundler }),
  postcssUrl('inline'),
  postcssExtend(),
  postcssFocus(),
  autoprefixer(),
  precss(),
  cssnano(),
];

postcss-url

PostCSS plugin to rebase or inline on url().

MIT
Latest version published 4 years ago

Package Health Score

77 / 100
Full package analysis