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

egg-easywebpack4

v0.0.2

Published

提供[egg-vue-spa-ssr-boilderplate](https://github.com/acthtml/egg-vue-spa-ssr-boilerplate) 开箱即用的webpack配置。

Downloads

3

Readme

egg-easywebpack

提供egg-vue-spa-ssr-boilderplate 开箱即用的webpack配置。

特性

  • 输出vue客户端、服务端的webpack配置。
  • webpack配置支持服务端渲染。
  • webpack配置支持HMR。
  • 根据webpack配置,构建成静态文件。
  • vue支持.vue。
  • 根据eggjs的环境变量加载配置。

约定

  1. vue所用架构的客户端和服务端入口分别为:
    • /app/web/entry_client.js
    • /app/web/entry_server.js
  2. ssr所用的html template为:
    • /app/web/views/app.template.html
  3. webpack编译的客户端静态产物在:
    • /public/static/
  4. 通过import '@config'获取当前配置。会根据当前环境来获取配置。例如,当EGG_SERVER_ENV=prod 时,实际获取的模块为/app/web/config/config.prod.js。这样做的目的时,根据环境,部署不 同的版本。
  5. 模块名前缀~指向的是前端根目录。例如import '~/common',实际获取的模块为/app/web/common

使用

  1. 获取webpack配置。
  const webpackConfig = require('egg-easywebpack');

  /**
   * 获取vue ssr项目的webpack配置。
   * @param  {String} type    配置类型:client或server
   * @param  {String} env     配置所在环境local/unittest/stage/prod
   * @param  {Object} options 选型,包含以下属性
   *                          - baseDir 站点根目录,默认 process.cwd()
   *                          - ip 代理ip
   *                          - port 代理端口
   *                          - enableHMR 开启热更新
   *                          - client 客户端产物配置
   *                            - publicPath output.publicPath
   *                            - path output.public.path
   * @return {Object}         webpack config
   */

  // 本地开发时的前后端配置,开启HMR。
  webpackConfig('client', 'local', {enableHMR: true});
  webpackConfig('server', 'local', {enableHMR: true});

  // 生产环境时的配置
  webpackConfig('client', 'prod', { client: {publicPath:'//cdn.example.com/'}})
  webpackConfig('server', 'prod', { client: {publicPath:'//cdn.example.com/'}})
  1. 根据webpack配置,构建成静态文件。
  • DIY形式。
  const build = reqire('egg-easywebpack/build');
  build()
    .then(() => console.log('done'))
    .catche(e => console.log('error'));
  • 命令形式。
  # package.json
  # "scripts": {
  #    "build": "easywebpack"
  # }
  eport EGG_SERVER_ENV=prod && npm run build