npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@lemmmy/craco-less

v1.18.0

Published

A Less plugin for craco / react-scripts / create-react-app

Downloads

5

Readme

Build Status Coverage Status MIT License


Community Maintained

We rely on your help to keep this project up to date and work with the latest versions of craco and react-scripts.

Before you send a PR, please check the following:

  • 100% test coverage
jest --coverage --testPathIgnorePatterns test-app
  • Code is formatted with Prettier
yarn prettier --write "**/*.{js,jsx,json,css,scss,html,md,yml}"
  • No ESLint warnings
yarn eslint --fix --ext .js lib/
  • No security vulnerabilities in any NPM packages
yarn audit

You are also welcome to add your GitHub username to the Contributors section at the bottom of this README. (optional)

Please don't send a pull request if it does not meet the above requirements

Pull requests will be ignored and closed if there is a failing build on Travis CI.


Craco Less Plugin

This is a craco plugin that adds Less support to create-react-app version >= 2.

Use react-app-rewired for create-react-app version 1.

Ant Design

If you want to use Ant Design with create-react-app, you should use the craco-antd plugin. craco-antd includes Less and babel-plugin-import (to only include the required CSS.) It also makes it easy to customize the theme variables.

Supported Versions

craco-less is tested with:

  • react-scripts: ^3.2.0
  • @craco/craco: ^5.5.0

Installation

First, follow the craco Installation Instructions to install the craco package, create a craco.config.js file, and modify the scripts in your package.json.

Then install craco-less:

$ yarn add craco-less

# OR

$ npm i -S craco-less

Usage

Here is a complete craco.config.js configuration file that adds Less compilation to create-react-app:

const CracoLessPlugin = require("craco-less");

module.exports = {
  plugins: [{ plugin: CracoLessPlugin }]
};

Configuration

You can pass an options object to configure the loaders and plugins. You can also pass a modifyLessRule callback to have full control over the Less webpack rule.

For example, to configure less-loader:

const CracoLessPlugin = require("craco-less");

module.exports = {
  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        lessLoaderOptions: {
          lessOptions: {
            modifyVars: {
              "@primary-color": "#1DA57A",
              "@link-color": "#1DA57A",
              "@border-radius-base": "2px"
            },
            javascriptEnabled: true
          }
        }
      }
    }
  ]
};

CSS Modules

You can configure the css-loader options to set up CSS modules. For example:

const CracoLessPlugin = require("craco-less");

module.exports = {
  plugins: [
    {
      plugin: CracoLessPlugin,
      options: {
        cssLoaderOptions: {
          modules: { localIdentName: "[local]_[hash:base64:5]" }
        }
      }
    }
  ]
};

CSS modules gotcha

There is a known problem with Less and CSS modules regarding relative file paths in url(...) statements. See this issue for an explanation.

(Copied from the less-loader README.)

Further Configuration

If you need to configure anything else for the webpack build, take a look at the Configuration Overview section in the craco README. You can use CracoLessPlugin while making other changes to babel and webpack, etc.

Contributing

Install dependencies:

$ yarn install

# OR

$ npm install

Run tests:

$ yarn test

Before submitting a pull request, please check the following:

  • All tests are passing
    • Run yarn test
  • 100% test coverage
    • Coverage will be printed after running tests.
    • Check the coverage results in your browser: open coverage/lcov-report/index.html
  • No ESLint errors
    • yarn lint
  • All code is formatted with Prettier
    • yarn format
    • If you use VS Code, you should enable the formatOnSave option.
  • Using the correct webpack version as a dependency
    • yarn update_deps
    • NOTE: The webpack dependency is needed to silence some annoying warnings from NPM. This must always match the version from react-scripts.

Releasing a new version

  • Make sure the "Supported Versions" section is updated at the top of the README.
  • Check which files will be included in the NPM package:
    • npm pack
    • Update .npmignore to exclude any files.
  • Release new version to NPM:
    • npm publish

License

MIT

Contributors