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

@douyinfe/semi-rspack-plugin

v2.69.0

Published

> A rspack plugin for Semi Design to custom theme、replace prefix and so on.

Downloads

1,852

Readme

A rspack plugin for Semi Design to custom theme、replace prefix and so on.

Introduction

The plugin is designed for Semi Design, support rspack, provides two major abilities:

  • Custom theme
  • Replace prefix of CSS selector

Usage

Install

Install @douyinfe/semi-rspack-plugin as a development dependency:

npm install --save-dev @douyinfe/semi-rspack-plugin
# or
yarn add --dev @douyinfe/semi-rspack-plugin

Custom theme

Semi Design uses the Scss variables to extract thousands of Design Tokens. You can replace Token through this plugin to achieve theme customization. More info

You can custom theme through three ways:

  • npm package for custom theme
  • Local Scss file in your project
  • Pass key-value pair parameters to plugin Priority from low to high.

Through npm package

In order to use the npm package, you need to customize the theme through Semi Design System.After finishing the customization, Semi DSM will generate a npm package for you, and then you can use it like this.

// rspack.config.js
const {SemiRspackPlugin} = require('@douyinfe/semi-rspack-plugin');

module.exports = {
    // ...
    plugins: [
        new SemiRspackPlugin({
            theme: '@douyinfe/semi-theme-default'
        })
    ]
    // ...
};

Through local Scss file

You can check which tokens can be customized on the Semi WebSite.

  • step1: add a local file
// local.scss
$font-size-small: 16px;
  • step2: config rspack
// rspack.config.js
const path = require('path');
const {SemiRspackPlugin} = require('@douyinfe/semi-rspack-plugin');

module.exports = {
    // ...
    plugins: [
        new SemiRspackPlugin({
            include: path.join(__dirname, 'local.scss')
        })
    ]
};

Through parameters

// rspack.config.js
const {SemiRspackPlugin} = require('@douyinfe/semi-rspack-plugin');

module.exports = {
    // ...
    plugins: [
        new SemiRspackPlugin({
            variables: {
                "$font-size-small": '16px'
            }
        })
    ]
};

Replace prefix of CSS selector

The CSS selectors used by Semi Design is prefixed with semi by default(e.g, .semi-button).You can replace the prefix through this plugin.

// rspack.config.js
const {SemiRspackPlugin} = require('@douyinfe/semi-rspack-plugin');

module.exports = {
    // ...
    plugins: [
        new SemiRspackPlugin({
            prefixCls: 'custom'
        })
    ]
    // ...
};

Then you get the replaced CSS selectors(e.g, .custom-button).

Api

new SemiPlugin(options)

options.prefixCls

Type: String

The prefix of CSS selector.

options.theme

Type: String or Object

When the type is string, it represents the name of npm for custom theme.You can use Semi Design System to custom theme.

options.theme.name

Same performance as when the type of options.theme is string.

options.include

Type: String

The absolute path of the local Scss file.

options.variables

Type: Object

The key-value pair of Scss token.

options.omitCss

Type: Boolean

In the compilation phase, whether to exclude css references.Used to solve the problem that Next.js does not support the global introduction of css in third-party code.See this discussion.

options.extractCssOptions.loader

Type: String

The path of webpack/rspack loader that extract css.

options.extractCssOptions.loaderOptions

Type: Object

The options of webpack/rspack loader that extract css.

options.overrideStylesheetLoaders

Type: (loaderList:any[])=>any[]

You can customize how webpack process semi related styles by override the loader with this option. The function will receive the loader list of default loaders(include options.extractCssOptions) and you should return your new loader list. The best practice is just only add your loader to the list rather than delete or change the default loaders since some core logic is in there.

In webpack@5, some hooks need to be obtained through api NormalModule.getCompilationHooks. But in some scenarios, webpack will not be installed, such as Next.js. Therefore, the user is required to pass in NormalModule as a parameter.