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

tpl-multipage-cli

v1.3.2

Published

多页面脚手架工具

Downloads

9

Readme

多页面的脚手架解决方案,提供页面拆分成多个模块进行维护,目前只适用于纯静态页面的开发,或者部分基于 ajax 的项目开发,或对于 seo 有要求的项目开发

特点

  • 使用 webpack 搭建,可以实现代码拆分,按需加载,可将视图与业务代码分离,资源管理
  • 集成了 ejs 的部分功能,可以使页面在开发工程中更加颗粒化,可维护性更高
  • 集成 babel,支持 es5+ 语法的使用,能支持到 ie9 的兼容
  • 集成了 less 样式的编写,同时集成 poctss 可自动对多款浏览器做兼容操作,也可以根据需求,添加额外插件进行移动端的自适应开发

兼容处理

请新增或者修改项目中 package.json 中的 browserslist 的值,具体请参考相关文档

配置 multipage.config.js

| 参数 | 必选 | 类型 | 默认值 | 备注 | | :--------------: | :---: | :--------------: | :----: | ----------------------------------------------------------------------------------------------------------------------------------- | | pages | | Array | 无 | 要导入的页面 | | publicPath | | String | ./ | 资源的存储路径,可以放 cdn 地址 | | devServer | | Object | | 参考 webpack 的 devServer 的配置 | | minify | | Boolean|Object | true | html 页面的优化选项,具体参数可看minification |

pages

一个路径代表一个页面,单个路径中视图层文件 ejs 和 业务文件 js 的文件名应该统一,否则无法识别

module.exports = {
  // 页面配置
  pages: ['pages/index/index', 'pages/about/about'],
};

publicPath

module.exports = {
  // 公共路径
  // publicPath: 'https://cdn.xxxx.com/static'
  publicPath: './',
};

devServer

module.exports = {
  // webpack 的 devServer 配置
  devServer: {
    port: 3000,
    host: '0.0.0.0',
  },
};

minify

module.exports = {
  // html 页面配置
  // minify: false,
  minify: {
    collapseWhitespace: true,
    removeComments: true,
    removeRedundantAttributes: true,
    removeScriptTypeAttributes: true,
    removeStyleLinkTypeAttributes: true,
    useShortDoctype: true,
  },
};

EJS 中部分语法

在这里我对 EJS 的使用,暂时是用于页面的拆分,方面维护;

模块的引入

<%= require('./indexHeader.ejs')() %>

图片的导入

<img src="<%= require('./images/bg.png').default %>" alt="bg" width="300">

css的导入

import './index.less';