@tenjo/webpack-config
Webpack Setup
Last updated 6 months ago by tenjojeremy .
ISC · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @tenjo/webpack-config 
SYNC missed versions from official npm registry.

Webpack Config

Installation

yarn add @tenjo/webpack-config

Create .webpack.manifest.js to root

Create .babelrc.js to root with:

module.exports = { extends: '/node_modules/tenjo-webpack-config/.babelrc' }

Add to Package.json

  "scripts": {
    "start": "yarn webpack-scripts start",
    "build": "yarn webpack-scripts build",
    "build-analyze": "yarn webpack-scripts build && yarn webpack-scripts analyze",
  },

Usage with project

Start development

yarn start

Create Build

yarn build

Analyze Build

yarn analyze

Add hot module reloading (HMR)

Install:

yarn add react-hot-loader

Add to index component, replace IndexComp as nessesary:

import { hot } from 'react-hot-loader/root'
const IndexComp = () => {}
export default hot(IndexComp)

Reference: https://github.com/gaearon/react-hot-loader

.webpack.manifest.js options example

const localIp = require('get-my-local-ip')

exports.manifest = {
  projectInfo: {
    name: 'Webpack Config',
    shortName: 'Webpack',
    description: 'Webpack Config',
    colors: {
      primary: '#6200ee',
      background: '#6200ee',
    },
    logo: {
      path: 'tests/logo.png',
    },
  },
  analytics: {
    google: {
      analytics: { gAnalyticFunctions: { onlyViewsScript: '' } },
    },
  },
  webpack: {
    devServer: {
      port: 3001,
      host: localIp.address,
    },
    entry: './tests/entry.js',
    plugins: {
      html: {
        bodyHtmlSnippet: '',
      },
      workbox: {
        swSrc: './tests/ServiceWorker/sw.js',
        swDest: 'sw.js',
      },
    },
  },
}

Usage with Libraries

Add to Package.json

  "scripts": {
    "build:library": "yarn webpack-scripts build:library"
  },

Build Library

yarn build:library

Add to a babelrc file

{ "extends": "./node_modules/@tenjo/webpack-config/.babelrc" }

.webpack.manifest.js options for a Library example

exports.manifest = {
  webpack: {
    entry: './features/index.js',
    output: {
      filename: 'index.js',
      libraryTarget: 'commonjs2',
    },
  },
}

How it works - Specs

The bin option in the package.json file has a file named webpack-scripts and you call it in the installed app by using yarn webpack-scripts start/build

Bundle Performance Checklist

Compression

  • Brotli

HTML

  • Minify
  • Remove comment
  • Remove new lines
  • Remove whitespaces

Javascript

  • Code split pages
  • minify bundle
  • Add js tag to head with defer attribute

CSS

  • preload css
  • add critical css to header

Images

  • Convert images to Webp

Fonts

  • use WOFF2 format
  • preload fonts
  • download font to use locally

Current Tags

  • 3.78.0                                ...           latest (6 months ago)

80 Versions

  • 3.78.0                                ...           6 months ago
  • 3.77.0                                ...           7 months ago
  • 3.76.0                                ...           7 months ago
  • 3.75.0                                ...           7 months ago
  • 3.74.0                                ...           8 months ago
  • 3.73.0                                ...           8 months ago
  • 3.72.0                                ...           8 months ago
  • 3.71.0                                ...           8 months ago
  • 3.70.0                                ...           8 months ago
  • 3.69.0                                ...           8 months ago
  • 3.68.0                                ...           9 months ago
  • 3.67.0                                ...           9 months ago
  • 3.66.0                                ...           9 months ago
  • 3.65.0                                ...           9 months ago
  • 3.64.0                                ...           9 months ago
  • 3.63.0                                ...           9 months ago
  • 3.62.0                                ...           9 months ago
  • 3.61.0                                ...           9 months ago
  • 3.58.0                                ...           9 months ago
  • 3.57.0                                ...           9 months ago
  • 3.56.0                                ...           9 months ago
  • 3.55.0                                ...           9 months ago
  • 3.54.0                                ...           9 months ago
  • 3.53.0                                ...           9 months ago
  • 3.52.0                                ...           9 months ago
  • 3.51.0                                ...           9 months ago
  • 3.50.0                                ...           9 months ago
  • 3.49.0                                ...           9 months ago
  • 3.48.0                                ...           9 months ago
  • 3.47.0                                ...           9 months ago
  • 3.46.0                                ...           9 months ago
  • 3.45.0                                ...           9 months ago
  • 3.44.0                                ...           9 months ago
  • 3.43.0                                ...           9 months ago
  • 3.42.0                                ...           9 months ago
  • 3.41.0                                ...           9 months ago
  • 3.40.0                                ...           9 months ago
  • 3.39.0                                ...           9 months ago
  • 3.38.0                                ...           9 months ago
  • 3.37.0                                ...           9 months ago
  • 3.36.0                                ...           9 months ago
  • 3.35.0                                ...           9 months ago
  • 3.34.0                                ...           9 months ago
  • 3.33.0                                ...           9 months ago
  • 3.32.0                                ...           9 months ago
  • 3.31.0                                ...           9 months ago
  • 3.30.0                                ...           9 months ago
  • 3.29.0                                ...           9 months ago
  • 3.28.0                                ...           9 months ago
  • 3.27.0                                ...           9 months ago
  • 3.26.0                                ...           9 months ago
  • 3.25.0                                ...           9 months ago
  • 3.24.0                                ...           9 months ago
  • 3.23.0                                ...           9 months ago
  • 3.22.0                                ...           9 months ago
  • 3.21.0                                ...           9 months ago
  • 3.20.0                                ...           9 months ago
  • 3.19.0                                ...           9 months ago
  • 3.18.0                                ...           9 months ago
  • 3.17.0                                ...           9 months ago
  • 3.16.0                                ...           9 months ago
  • 3.15.0                                ...           9 months ago
  • 3.14.0                                ...           9 months ago
  • 3.13.0                                ...           9 months ago
  • 3.12.0                                ...           9 months ago
  • 3.11.0                                ...           9 months ago
  • 3.10.0                                ...           9 months ago
  • 3.9.0                                ...           9 months ago
  • 3.8.0                                ...           9 months ago
  • 3.7.0                                ...           9 months ago
  • 3.6.0                                ...           9 months ago
  • 3.5.0                                ...           10 months ago
  • 3.4.0                                ...           10 months ago
  • 3.3.0                                ...           10 months ago
  • 3.2.0                                ...           10 months ago
  • 3.1.0                                ...           10 months ago
  • 3.0.0                                ...           10 months ago
  • 2.18.0                                ...           10 months ago
  • 2.17.0                                ...           10 months ago
  • 2.16.0                                ...           10 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 161
Last Day 0
Last Week 161
Last Month 80
Dependencies (58)
Dev Dependencies (3)

Copyright 2014 - 2017 © taobao.org |