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

san-anode-loader

v0.3.2

Published

一个将san单文件组件中的template编译为anode或apack的loader

Downloads

21

Readme

san-anode-loader

san-anode-loader 是一个可以将 san 单文件组件或js中的模版部分编译为 aPack 或 aNode 形式的 webpack loader

合并了此项目:https://github.com/luoyimaid/san-template-loader

安装

使用 npm:

npm i san-anode-loader

使用 yarn:

yarn add san-anode-loader

使用

examples 中编写了一个最简单的、完整的项目示例。

下面是配置文件:

{
    test: /\.pug$/,
    use: [
        {
            loader: "html-loader",
        },
        {
            loader: 'san-anode-loader',
            options: {
                compileTemplate: "aNode",
            },
        },
        {
            loader: "pug-plain-loader",
        },
    ],
},
{
    test: /\.html$/,
    use: [
        {
            loader: "html-loader",
            options: {
                esModule: false,
                minimize: false,
            },
        },
        {
            loader: 'san-anode-loader',
            options: {
                compileTemplate: "aPack",
            },
        },
    ],
},
{
    test: /\.js$/,
    use: [
        {
            loader: 'babel-loader',
            options: {
                plugins: [
                    require.resolve(
                        '@babel/plugin-proposal-class-properties'
                    ),
                    require.resolve(
                        'san-hot-loader/lib/babel-plugin'
                    ),
                ],
                presets: [
                    [
                        require.resolve('@babel/preset-env'),
                        {
                            targets: {
                                browsers: '> 1%, last 2 versions',
                            },
                            modules: false,
                        },
                    ],
                ],
            },
        },
        {
            loader: 'san-anode-loader',
            options: {
                compileTemplate: 'aPack',
                mode: 'compact',
            },
        },
    ],
},

处理单文件组件

当使用如 pug 类的 html 模版时,确保先走模板的 loader 然后再走 san-anode-loader,因为 san-loader 不能编译不是标准 html 的代码片段。

处理 js 中的template

mode代表模式:

  • 严格模式 strict

  • 兼容模式 compact

严格模式下,template 不可以出现字符串表达式,否则会报错,兼容模式下,会跳过有字符串表达式的 template

注意事项

目前兼容到 webpack5,但因为 html-loader2 有兼容性问题,所以同样的项目配置在 5 中会有问题,请移步 html-loader 讨论区

问题反馈

可移步 san discussion 讨论区

License

MIT © vanishcode

MIT © luoyimaid