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

@systemlight/webpack-config

v6.7.3

Published

Webpack smart configuration.

Downloads

1

Readme

@systemlight/webpack-config

NPM version

Webpack smart configuration.

Support

  • [x] webpack5
  • [x] babel
  • [x] mockjs
  • [x] typescript
  • [x] css
  • [x] postcss
  • [x] sass
  • [x] less
  • [x] stylus
  • [x] react
  • [x] vue

Usage

Install

npm i @systemlight/webpack-config webpack -D
or
yarn add @systemlight/webpack-config webpack -D
or
pnpm add @systemlight/webpack-config webpack -D

Usage

Generate webpack.config.js

wcf init

Pop up configuration file

wcf inspect
wcf inspect build --mode production
wcf inspect server --mode production

Options

All configuration items are default values generated by the intelligent detection environment, and no configuration is required without special requirements

Case

  • Additional split code configuration
const {wcf} = require('@systemlight/webpack-config')

module.exports = wcf({
  enableDevtool: false,
  chainWebpack(config, context) {
    context.configSplitChunks((options) => {
      options.cacheGroups['foos'] = {
        name: 'fooa',
        test: /foo/,
        enforce: true,
        priority: 10
      }
    })
  }
})
  • Ignored files should not have calls to import, require, define or any other importing mechanism
const {wcf} = require('@systemlight/webpack-config')

module.exports = wcf({
  enableDevtool: false,
  emitHtml: false,
  chainWebpack(config) {
    config.module.noParse(/jquery|lodash/)
  }
})
  • Access global jQuery
const {wcf} = require('@systemlight/webpack-config')

module.exports = wcf({
  enableDevtool: false,
  chainWebpack(config, context) {
    config.module.rule('jquery')
      .test(/jquery/)
      .use('expose-loader')
      .loader('expose-loader')
      .options({
        exposes: ['$', 'jQuery']
      })

    context.configSplitChunks((options) => {
      options.cacheGroups['jquery'] = {
        name: 'jquery',
        test: /jquery/,
        enforce: true,
        priority: 10
      }
    })
  }
}, false)
const {wcf} = require('@systemlight/webpack-config')
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin')

module.exports = wcf({
  enableDevtool: false,
  configureWebpack: {
    plugins: [
      new AddAssetHtmlPlugin({
        filepath: require.resolve('jquery')
      })
    ]
  }
}, false)
  • Pop up TS type declaration file
module.exports = wcf({
  enableHash: false,
  isNodeEnv: true,
  libraryName: 'Fuse',
  chainWebpack(config) {
    config.module.rule('ts/tsx').use('ts-loader').tap((args) => {
      args['transpileOnly'] = false
      args['compilerOptions']['noEmit'] = false
      return args
    })
  }
})
  • Custom inject label
const {wcf} = require('@systemlight/webpack-config')
const AddAssetHtmlPlugin = require('add-asset-html-webpack-plugin')

module.exports = wcf({
  enableDevtool: false,
  configureWebpack: {
    plugins: [
      new AddAssetHtmlPlugin({
        filepath: require.resolve('jquery')
      })
    ]
  },
  chainWebpack(config) {
    config.plugin('HtmlWebpackPlugin').tap((args) => {
      args[0].inject = false
      args[0].scriptLoading = 'blocking'
      return args
    })
  }
}, false)
<!doctype html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title><%= htmlWebpackPlugin.options.title %></title>
    <%= htmlWebpackPlugin
            .tags
            .bodyTags
            .filter((tag) => /jquery/.test(tag.attributes.src))
            .join('')
    %>
</head>
<body>
<div id="root"></div>
<%= htmlWebpackPlugin
        .tags
        .bodyTags
        .filter((tag) => !(/jquery/.test(tag.attributes.src)))
        .join('')
%>
</body>
</html>
  • Injects a custom string into the body
const {wcf} = require('@systemlight/webpack-config')

module.exports = wcf({
  port: 8000,
  injectHtml:{content:'<div id="root"></div>', position:'start'}
})

Notice!!!

  • If you are developing a library or a multi project repository (monorepo), please note that importing CSS has side effects
  • Please make sure that the package Remove "sideEffects" in json: false,
  • Otherwise, the CSS code block will be lost by the webpack when the production environment is built