@swissquote/crafty-preset-lightningcss

1.25.0 • Public • Published
Compatible Runners

[TOC]

Description

The principle of CSS is easy to grasp, yet CSS is complicated to write at large scales.

We want to offer the best experience for writing CSS that is compatible with most browsers without the long configuration process.

Features

LightningCSS is a CSS Processor that will take your CSS, and make it compatible with the largest number of browers. Write tomorrow's CSS today.

Linting

Stylelint is a wonderful tool to lint CSS in according to your rules, we have a custom configuration preset for Stylelint that comes pre-configured.

Stylelint is provided automatically in this preset by also including crafty-preset-stylelint.

Installation

npm install @swissquote/crafty-preset-lightningcss --save
module.exports = {
  presets: [
    "@swissquote/crafty-preset-lightningcss",
    "@swissquote/crafty-runner-webpack"
  ]
};

Usage with Webpack

Webpack defines the right loaders to support CSS.

To use it, add import "myfile.scss" in your Webpack imported file.

Hot Module Replacement

When setting hot: true in your crafty.config.js for your main JavaScript bundle, you can enable Hot Module Replacement.

With this, the CSS files imported in your Webpack bundles are automatically reloaded upon changes.

This is used inside crafty watch, the build mode will not take it into account.

Extracting CSS

By default, the CSS will be embedded in your bundle, but you can provide the extractCSS option to extract your styles using the MiniCssExtractPlugin.

extractCSS controls if the CSS should be embedded within the JavaScript bundle or extracted in a separate file. By default, the default is that the CSS content remains within the main file.

Possible options

Value Note
false Default Behaviour, CSS stays in the JavaScript bundle, added to the page via a <style> tag.
true Will enable extraction and name files with the [bundle]-[name].min.css pattern.
String / Object Supports all Official options. with the addition of [bundle] which is replaced by the bundle name.

Side effects

Be careful when using extractCSS option and sideEffects: false in package.json of your project. Crafty is using css-loader and when you import a CSS file in your project, it needs to be added to the side effect list so it will not be unintentionally dropped in production mode.

Webpack docs and examples

Bundle Options

Option Type Optional ? Runner Description
extractCSS Boolean / String / Object Yes Webpack This will extract the CSS out of the bundle. See details above.

Readme

Keywords

none

Package Sidebar

Install

npm i @swissquote/crafty-preset-lightningcss

Weekly Downloads

6

Version

1.25.0

License

Apache-2.0

Unpacked Size

622 kB

Total Files

29

Last publish

Collaborators

  • david.joaquim
  • mofleury
  • stephane.goetz