GithubHelp home page GithubHelp logo

glenntws / stencil-postcss Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stencil-community/stencil-postcss

0.0 0.0 0.0 114 KB

Autoprefixer plugin for Stencil

Home Page: https://www.npmjs.com/package/@stencil/postcss

License: Other

JavaScript 4.45% TypeScript 95.55%

stencil-postcss's Introduction

@stencil/postcss

This package is used in order to integrate with postcss and all of its plugins.

First, npm install within the project:

npm install @stencil/postcss --save-dev

Next, within the project's stencil.config.ts file, import the plugin and add it to the plugins config. In the example below we're using the autoprefixer postcss plugin, so you'll also have to run:

npm install autoprefixer @types/autoprefixer --save-dev

This plugin requires Node.js 14 or higher. For older Node versions, see the 1.x release.

stencil.config.ts

import { Config } from '@stencil/core';
import { postcss } from '@stencil/postcss';
import autoprefixer from 'autoprefixer';

export const config: Config = {
  plugins: [
    postcss({
      plugins: [autoprefixer()]
    })
  ]
};

During development, this plugin will use postcss to process any plugins you may have passed along.

Options

Postcss has an ecosystem of plugins itself (a plugin for a plugin if you will). For our example, we're using the autoprefixer plugin, and configuring its options. Note, you can pass any valid autoprefixer option.

exports.config = {
  plugins: [
    postcss({
      plugins: [
        autoprefixer({
          browsers: ['last 6 versions'],
          cascade: false
        })
      ]
    })
  ]
};

Inject Globals Paths

The injectGlobalPaths config is an array of paths that automatically get added as @import declarations to all components. This can be useful to inject variables, mixins and functions to override defaults of external collections. Relative paths within injectGlobalPaths should be relative to the stencil.config.js file.

exports.config = {
  plugins: [
    postcss({
      injectGlobalPaths: [
        'src/globals/variables.pcss',
        'src/globals/mixins.pcss'
      ]
    })
  ]
};

Note that each of these files are always added to each component, so in most cases they shouldn't contain CSS because it'll get duplicated in each component. Instead, injectGlobalPaths should only be used for Sass variables, mixins and functions, but not contain any CSS.

Valid file extensions

This plugin will only transpile files whose extensions are .css, .pcss, or .postcss.

Related

Contributing

Please see our Contributor Code of Conduct for information on our rules of conduct.

stencil-postcss's People

Contributors

adamdbradley avatar claviska avatar manucorporat avatar mhartington avatar bfmatei avatar splitinfinities avatar sanderand avatar ghaiat avatar jagreehal avatar kgroat avatar paulcpederson avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.