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

webab

v1.1.1

Published

JavaScript Front-End Build Tool

Downloads

6

Readme

Webab

提供开箱即用零配置的前端打包工具,全局安装,到处使用 基于webpack4+babel7,无需安装任何依赖,支持 jsx tsx ts js + css less sass 项目地址:https://github.com/anuny/webab

🛒安装

npm i webab -g

🐞调试模式

webab 或者 webab dev

📦编译模式

# 打包生产模式
webab build

# 打包开发模式
webab build -dev

🔨配置

  • 无需配置即可使用,项目默认入口文件为./src/main,支持js、jsx、ts、tsx文件;默认html模板文件为./src/index.html
  • 如需自定义配置,配置文件为 ./webab.config.js
// 示例
module.exports = {
  app:{},
  dirs:{},
  extensions:[],
  ...
}

app

自定义参数,应用内通过 process.env.app 获取 type any

dirs

基础路径配置 type Object

// 默认
dirs:{
  src : 'src',
  public: 'public',
  dist: 'dist'
}

extensions

自动解析的扩展名。参考 webpack extensions type Array

// 默认
extensions:['.js', '.jsx','.ts','.tsx','.json','.vue','.css','.less','.sass','.scss']

alias

创建 importrequire 的别名,使模块引入变得更简单。参考 webpack alias type Object

// 默认
alias:{
  'vue$': 'vue/dist/vue.esm.js', 
  '#' : path.resolve(__dirname),  
  '@' : path.resolve('src' ) 
}

entry

入口文件配置,参考 webpack entry type Object

// 默认
entry:{
  main : path.resolve('src', 'main')
}

template

html模板文件配置,支持多页面,为空则不打包html文件。参考 html-webpack-plugin type Object

// 默认
entry:{
  'index.html': path.resolve('src', 'index.html')
}

favicon

favicon.ico配置 type String

favicon: path.resolve('src', 'favicon.ico')

fileName

输出文件名配置 参考 webpack output.filename type Object

fileName:{
  js:'[name].js', 
  css:'[name].css', 
  img:'[name].[ext]', 
  font:'[name].[ext]'
}

dev

开发调试配置, 参考 webpack.devtool webpack.output.publicpath type Object

dev:{
  host:'0.0.0.0',
  port:'8080',
  devtool:'cheap-module-eval-source-map',
  publicPath:''
}

build

生产打包配置 type Object

build:{
  devtool:'none',
  publicPath:''
}

provide

自动加载模块配置,参考 webpack.providePlugin type Object

jsx

jsx配置,默认使用React。参考 babel-react-jsx type Object

jsx:{
  pragma:'...',
  pragmaFrag:'...'
}

globalStyle

全局样式文件配置, 参考 sass-resources-loader type String

// 默认
globalStyle:'assets/css/vars'

📑获取参数

运行时变量 NODE_ENV 值为:development or production 自定义变量 app 默认 undefined

  • 在配置文件里使用
// 示例:为不同的运行环境设置不同的logo图片地址
const mode = process.env.NODE_ENV
module.exports = {
  app:{
    logo:`./images/${mode}/logo.jpg`
  },
  ...
}
  • 在html模板里使用
<!-- 获取运行时变量 -->
<%= webab.NODE_ENV %>
<!-- 获取自定义变量 -->
<%= webab.app.xxx %>
  • 在项目javascript里使用
// 获取运行时变量
const mode = process.env.NODE_ENV
// 获取自定义变量
const app= process.env.app