@neogeek/custom-webpack-cli

3.0.2 • Public • Published

@neogeek/custom-webpack-cli

🎒 A no-frill webpack cli that requires next to nothing to get started.

NPM Version

Features

  • React 18
  • TypeScript 5
  • Styled Components
  • Sass

Install

$ npm install @neogeek/custom-webpack-cli --save-dev

Usage

package.json

{
  "dependencies": {
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "styled-components": "^6.1.1"
  },
  "devDependencies": {
    "@neogeek/custom-webpack-cli": "^3.0.0"
  },
  "scripts": {
    "start": "custom-webpack-dev-server-cli",
    "build": "custom-webpack-cli"
  },
  "private": true
}

src/js/index.jsx

import ReactDOM from 'react-dom';

const HelloMessage = ({ name }) => <div>Hello {name}</div>;

ReactDOM.render(<HelloMessage name="Taylor" />, document.querySelector('body'));

Static Files

All static files (images, audio, video files) should be placed in a folder names public/ at the root of the project.

Customization

To customize the webpack config, add a webpack.custom.js to the root of your project. The contents of that file will be merged with the webpack.config.js file distributed with this tool.

Transpile Custom node_module Packages

module.exports = {
  module: {
    rules: [
      {
        test: /\.s[ac]ss$/i,
        exclude: /node_modules\/(?!custom-component-library)/u,
        include: /.*/
      },
      {
        test: /\.tsx?$/u,
        exclude: /node_modules\/(?!custom-component-library)/u,
        include: /.*/
      },
      {
        test: /\.jsx?$/u,
        exclude: /node_modules\/(?!custom-component-library)/u,
        include: /.*/
      }
    ]
  }
};

Open Page on Launch

module.exports = {
  devServer: {
    open: true,
    openPage: 'blog/'
  }
};

Compile as a CommonJS Module (without including React & ReactDOM)

const { resolve } = require('path');

module.exports = {
  externals: {
    react: 'react',
    reactDOM: 'react-dom'
  },
  output: {
    filename: 'bundle.min.js',
    path: resolve(process.cwd(), 'dist'),
    publicPath: '/',
    library: {
      type: 'commonjs2'
    }
  }
};

Readme

Keywords

none

Package Sidebar

Install

npm i @neogeek/custom-webpack-cli

Weekly Downloads

1

Version

3.0.2

License

MIT

Unpacked Size

11.7 kB

Total Files

6

Last publish

Collaborators

  • neogeek