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

zen-react-scripts

v0.2.0

Published

[webpack@5](https://github.com/webpack/webpack) scripts for building and developing React SPA's. Works great with [create-zen-app](https://github.com/fatihgozenc/create-zen-app) which is based on this repo for webpack scripts and configuration. Inspired f

Downloads

51

Readme

Zen React Scripts

webpack@5 scripts for building and developing React SPA's. Works great with create-zen-app which is based on this repo for webpack scripts and configuration. Inspired from react-scripts.

This project aims to contain have latest updates from all dependencies to be secure and prevent any warning on actions or npm/yarn log messages.

Also you're able to use Web Workers with TypeScript with this.

Install

Final build will be compiled into preact and @babel/runtime will optimize re-use of classes in runtime. So:

yarn add preact @babel/runtime
npm i preact @babel/runtime

then you're ready to go:

yarn add -D zen-react-scripts
npm i -D zen-react-scripts

Folder Structure

my-app
├── README.md
├── node_modules
├── package.json
├── .gitignore
├── .eslintrc.json
├── .env
├── public
│   ├── manifest.json
│   └── index.html
└── src
    ├── components/
    ├── App.tsx
    ├── preload.js
    ├── index.js
    └── logo.svg

Sample config for package.json

    "scripts": {
        "dev": "zen-react-scripts dev",
        "build": "zen-react-scripts build",
        "local": "zen-react-scripts local"
    }
    "browserslist": "edge >= 13, firefox >= 50, and_ff >= 50, chrome >= 49, and_chr >= 49, ios >= 9.4, safari >= 9.4, samsung >= 5, and_uc >= 11.8, opera >= 40, op_mob >= 40, baidu >= 7"

Environment Files

By default .env file will be checked for environment variables. If you place .env.production or .env.development, these files will overwrite default .env file that you've placed before.

Commands

dev

Starts project for development on http://localhost:3000 and opens a tab in your default browser.

--https

Starts development server with https.

--silent or -s

Starts development server in the background, without creating a tab or opening the browser. Useful for testing.

build

Builds the react project for deployment. Will be placed in ./build/

local

Builds the project and starts an instance on http://localhost:3001 via a basic express static server. Useful for checking the build on production environment.

start

Starts built project for production on http://localhost:3001.

--hash

Builds your app with a unique random hash like app.9dbf42.js in all of your assets. If not specified it uses [contenthash:6] which only changes when you change the content of the file. via NPM

npm run build -- --hash

via Yarn

yarn build --hash

--analyze

Builds and creates a report on http://localhost:3002

via NPM

npm run build -- --analyze

via Yarn

yarn build --analyze

Custom Webpack Configuration

You can overwrite the custom configuration of your app via placing webpack.config.js in your project root. Webpack configurations can passed inside production and development keys in object.

module.exports = {
  production: {
    output: {
      publicPath: "/yourDesiredPath/",
    },
  },
  development: {
    devtool: "source-map",
  },
};

Web Workers with React

Now you can start using Web Workers! Two things are important here: Files that contain a Web Worker must end with *.worker.ts, and they must start with the following two lines of code in order to work nicely together with TypeScript:

declare const self: DedicatedWorkerGlobalScope;
export default {} as typeof Worker & { new (): Worker };

// Your code ...

In your application, you can import your Web Workers like a normal module, and instantiate them as a class. For example:

import MyWorker from "./MyWorker.worker";

const myWorkerInstance: Worker = new MyWorker();

Loading Custom Font Files

Loading custom files via URL relies on relative paths in your file tree. An example with file tree is here:

// src/styles/main.scss
@font-face {
  font-family: "FFMark";
  src: url("./fonts/ffmark.woff2");
}

└─ src
  ├── components/
  ├── styles/
  │   ├── fonts/
  │   │   └── ffmark.woff2
  │   └── main.sscs
  ├── App.tsx
  └── index.js