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

axml-loader

v0.1.2

Published

axml loader for webpack

Downloads

9

Readme

axml-loader

针对支付宝小程序 axml 文件的 webpack 加载器,支持SFC(Single File Component)。

Install

    npm i axml-loader --save-dev

推荐安装 multi-entry-plugin 自动配置多个entry

    npm i multi-entry-plugin --save-dev

Config

webpack.config.js

import MultiEntryPlugin from 'multi-entry-plugin';

export default {
  entry: {
    app: './src/app.axml'
  },
  module: {
    rules: [{
      test: /\.axml$/,
      use: [
        {
          loader: 'axml-loader'
        }
      ]
    }]
  },
  output: {
    filename: '[name].js',
    path: resolve(__dirname, '../dist')
  },
  plugins: [
      new MultiEntryPlugin({
        mainEntry: 'app'
      })
  ]
  // ...
}

SFC(单文件组件)

Example

<template>
	<view class="container">
		<view class="item"></view>
	</view>
</template>

<script type="application/json">
	{
		"usingComponents": {
			"component1": "/components1"
		}
	}
</script>

<script>
  const app = getApp();

  Page({
    onLoad() {
      console.log('onLoad')
    },

    onShow() {
      console.log('onShow')
    }
  });
</script>

<style>
	.container{
		font-size: 18px;
	}
	.item{
		width: 200Px;
	}
</style>

单文件组件分为四部分:模板(template)、配置(config)、js和样式(style),对应原生小程序单一模块的 axml 文件、json 文件、js 文件、acss 文件。

template

使用 template 标签。

| 原生写法 | 简化写法 | | ------------------------------------------------------ | ------------------------------ | | a:if="{{isShow}}" | a-if="isShow" | | a:else | a-else | | a:elif="{{isShow}}" | a-else-if="isShow" | | a:for="{{list}}" a:for-item="item" a:for-index="index" | a-for="(item, index) in list" | | a:key="key" | a-key="key" | | attr="{{data}}" | :attr="data" |

原生写法可与简化写法同时使用,不受影响。

<template>
	<view class="container">
		<view class="item" a-if="value > 3">
			>3
		</view>
		<view class="item" a-else-if="value > 2">
			>2
		</view>
		<view class="item" a-else="value > 1">
			>1
		</view>
		<view class="item" a-for="(item, index) in list" a-key="*this">
			{{index}} -> {{item}}
		</view>
	</view>
</template>

config

使用带 type="application/json" 属性的 script 标签,或使用 config 标签。

<config>
	{
		"usingComponents": {
			"component1": "/components1"
		}
	}
</config>

js

使用 script 标签,支持使用 src 属性引入文件,此时会忽略标签中的 js 代码。

<script src="./index.js">
  const app = getApp();

  Page({
    onLoad() {
      console.log('onLoad')
    },

    onShow() {
      console.log('onShow')
    }
  });
</script>

style

使用 style 标签,支持使用 sass 和 less 等语法,需要手动安装对应语法的 loader。支持使用 src 属性引入文件。

<style lang='sass'>
	.container{
		font-size: 18px;
    .item{
      width: 200Px;
    }
	}
</style>
<style lang='sass' src="./style.scss"></style>