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

moga-app-base-webpack-config

v2.0.0

Published

Basic webpack configuration used by Moga application

Downloads

7

Readme

moga-app-base-webpack-config

Basic webpack configuration used by Moga application

介绍

moga-app-base-webpack-config是用于构建Moga App的基础webpack配置,其内部使用webpack-chain实现。

除此之外,moga-app-base-webpack-config还提供了react编译所需的babel配置。

API

moga-app-base-webpack-config对外提供如下API,使用该API就可以得到对应的基础配置:

  1. getBabelConfig 得到react相关的babel配置
  2. getWebpackConfig 得到基础的webpack配置

getBabelConfig

getBabelConfig的实现如下,可以看到具体的babel配置:

export = (isEnvDevelopment = false) => {
  return {
    presets: [
      [require.resolve('@babel/preset-env'), {}],
      [require.resolve('@babel/preset-react'), { runtime: 'automatic' }],
      require.resolve('@babel/preset-typescript'),
    ],
    plugins: [
      true
      && isEnvDevelopment
      && require.resolve('react-refresh/babel'),
    ].filter(Boolean),
    babelrc: false,
    configFile: false,
  };
};

getWebpackConfig

getWebpackConfig的实现如下:

import getBaseConfig = require('./webpack.base');
import getBuildConfig = require('./webpack.build');
import getDevConfig = require('./webpack.dev');
import { Config, Mode } from '../../types';

export = (mode: Mode = 'development', config: Config) => {
  getBaseConfig(mode, config);
  if (mode === 'development') {
    getDevConfig(config);
  } else {
    getBuildConfig(config);
  }
  return config;
};

根据mode的值可以获取开发、生产环境下的配置。

基础配置

开发和生产环境下公用的配置如下:

  1. resolve中extensions的配置:['.js', '.json', '.jsx', '.ts', '.tsx']
  2. 对css、css module、less、sass、字体、等其他资源的处理
  3. 对(js|mjs|jsx|ts|tsx)类型文件的babel配置处理

开发环境配置

开发环境在基础配置上增加如下配置:

  1. soure map: cheap-module-source-map
  2. react热更新支持

生产环境配置

生产环境在基础配置上增加如下配置:

  1. optimization配置,对js和css资源压缩和其他优化

更多配置,请阅读moga-app-base-webpack-config,其实现并不难。