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

rollup-plugin-san

v2.0.1

Published

A rollup plugin supports `.san` file.

Downloads

20

Readme

rollup-plugin-san

rollup-plugin-san 是一个支持 .san 单文件组件的 rollup 插件。

rollup-plugin-san

类似 webpack 的 san-loader 插件,它同样支持以下特性:

  • scoped css

  • css modules

  • less 等 css 预处理器(需要自行安装配套包)

  • pug 等 html 预处理器(需要自行安装配套包)

  • typescript 等 js 方言(需要自行安装配套包)

  • aNode / aPack => 文档

等等。

快速上手

安装:

npm i rollup-plugin-san --save-dev

然后编写 rollup.config.js

import PluginSan from 'rollup-plugin-san';

export default [
  {
    input: 'src/App.san',
    output: {
      file: 'dist/app.js',
      format: 'esm',
      sourcemap: 'none',
    },
    plugins: [PluginSan()],
    external: ['san'],
  },
];

examples 里包含了绝大多数的开发场景的示例,比如热更新、压缩混淆、图片引入、ts 支持、copy 文件等等。

设置

| 名称 | 描述 | 类型 | | ---------------------- | -------------------- | -------------------------------------- | | include | 包含的文件或目录 | string / RegExp / (string / RegExp)[]; | | exclude | 排除的文件或目录 | string / RegExp / (string / RegExp)[]; | | templateCompileOptions | compileTemplate 选项 | Object | | styleCompileOptions | compileStyle 选项 | Object |

templateCompileOptions 和 styleCompileOptions 详见 san-sfc-compiler

说明

插件

  • rollup 插件执行顺序和配置文件数组顺序是一致的,所以配置时候注意先后顺序

  • css 的处理需要安装 rollup-plugin-postcss

  • 一般来说 @rollup/plugin-node-resolve 是必备的,不然会出现找不到模块的问题

  • 默认输出 ESM 模块,可自行配置 babel 来转换语法

打包

  • 分包,参考 examples/complex 的 rollup.config.js,此时 san 可以通过 cdn 引入

  • 全量打包需要 rollup 的 commonjs 插件,并将 external 和 output.global 去掉,这样 san 才能全部打包到一起

其他

关于 sfc 写法可参考 webpack san-loader,这里不再重复

反馈

所有 san 相关的项目都支持以下反馈方式:

协议

MIT. Copyright (c) Baidu Inc. All rights reserved.

参考

感谢以下项目: