Skip to content

novlan1/plugin-light

Folders and files

NameName
Last commit message
Last commit date

Latest commit

6f27b1b · Jan 15, 2025
Jan 15, 2025
Sep 21, 2024
Mar 1, 2024
May 26, 2023
Jan 15, 2025
Sep 21, 2024
Jan 15, 2025
Jan 15, 2025
Sep 21, 2024
Jul 30, 2024
Oct 24, 2022
Dec 14, 2024
Oct 24, 2022
Sep 21, 2024
Sep 21, 2024
Oct 24, 2022
Aug 23, 2023
Dec 14, 2024
Jan 15, 2025
Oct 24, 2022
Sep 21, 2024
Jan 15, 2025
Sep 21, 2024
Sep 21, 2024

Repository files navigation

Plugin Light

Plugin Light 是一个丰富、易用的工具集。包含一些 Webpack 相关插件(25+),比如

以及一些 Webpack Loader(20+)

一些 Vite Plugin(23+)

一些 Webpack 基础配置

Postcss Plugin

基础包

安装

每个包名称不同,下面是一个示例:

npm install -D @plugin-light/project-config-vite

插件使用示例

// vue.config.js

const { DispatchScriptPlugin } = require('@plugin-light/webpack-plugin-dispatch-vue');

let plugins = []

if (process.env.NODE_ENV === 'production') {
  // js分发
  plugins.push(new DispatchScriptPlugin());
}

module.exports = {
  configureWebpack: {
    plugins,
  }
}

Webpack PluginVite PluginProject Config 均可以采用这种引入方式。

Loader 使用示例

每个 Webpack Loader 都会导出 LOADERLOADER_PROD 两个变量,分别对应 loader.jsloader.prod.js 的文件路径。

业务可以像下面这样使用:

// vue.config.js

const { LOADER: ifdef } = require('@plugin-light/webpack-loader-ifdef');

module.export = {
  chainWebpack(config) {
    config.module
      .rule('ifdef-loader')
      // 根据项目实际配置文件类型
      .test(/press-ui.*(\.vue|\.ts|\.js|\.css|\.scss)$/)
      // 不要配成下面这样,会卡住
      // .test(/\.vue|\.ts|\.js|\.css|\.scss$/) 
      .use(ifdef)
      .loader(ifdef)
      .options({
        context: { H5: true },
        type: ['css', 'js', 'html'],
      })
      .end();
  }
}

详细文档

点此查看

迁移至 monorepo

  1. plugin-light 不再维护,后续只更新 monorepo 包。

  2. 如需使用 light-cli publish 命令,请安装 webpack-loader-publish

  3. sync-repo 功能已经废弃。

  4. stylelint-plugin/no-useless-css 插件已经废弃。