Giter Club home page Giter Club logo

webpack-nano's Introduction

webpack-nano

webpack-nano tests cover size libera manifesto

A teensy, squeaky 🐤 clean Webpack CLI

webpack-nano operates on the premise that all options for configuring a webpack build are set via a config file.

Install

Using npm:

npm install webpack-nano --save-dev

Requirements

webpack-nano is an evergreen module. 🌲 This module requires an Active LTS Node version (v10.0.0+).

Benefits

  • Holy bananas 🍌 it's itsy bitsy
  • Doesn't hit you over the head with an avalanche of flags and options
  • Allows any number of user-defined flags
  • It does one thing: tells webpack to start a build
  • ~90% smaller than webpack-cli and webpack-command

Usage

$ npx wp --help

  Usage
    $ wp [...options]

  Options
    --config          A path to a webpack config file
    --config.{name}   A path to a webpack config file, and the config name to run
    --json            Emit bundle information as JSON
    --help            Displays this message
    --silent          Instruct the CLI to produce no console output
    --version         Displays webpack-nano and webpack versions

  Examples
    $ wp
    $ wp --help
    $ wp --config webpack.config.js
    $ wp --config.serve webpack.config.js

Custom Flags

With webpack-cli users are limited as to the flags they can use on with the $ webpack binary, and are instructed to use the --env flag for custom data. Well that's just 🍌🍌. With webpack-nano users can specify an unlimited number of custom flags, without restriction.

Say you have a bundle which can be built to use different asset locations from cloud data sources, like Amazon S3 or Google Cloud Storage. And in this scenario you prefer to specify that location using a command-line flag. If you were using webpack-cli, you'd have to use the --env.source flag (or you'd get a big 'ol error) and use a function for your webpack.config.js export. Using webpack-nano:

$ wp --config webpack.config.js --source s3
// webpack.config.js
const argv = require('webpack-nano/argv');

const { source } = argv;

module.exports = {
  ...
}

✨ Magic. The webpack-nano/argv export provides quick and easy access to parsed command-line arguments, allowing the user to define the CLI experience as they want to.

Special Configuration File Types

Webpack configuration files can be written using a variety of module loaders. e.g. Babel or TypeScript. webpack-nano allows users to use file types like webpack.config.babel.js, webpack.config.es6, webpack.config.mjs, and webpack.config.ts. Users are responsible for installing a compatible module loader when using these special file types. The table below represents the supported file types and their compatible loaders:

Extension Compatible Loaders
.babel.js @babel/register, babel-register, babel-core/register, babel/register
.babel.ts @babel/register
.es6 @babel/register
.mjs @babel/register
.ts ts-node/register, typescript-node/register, typescript-register, typescript-require

Build Stats

This project attempts not to make assumptions about how a build should behave, and that includes webpack stats. By default, webpack-nano will apply two stats options: colors (based on supports-color and exclude: ['node_modules']). These can be quickly overridden by including these key/values in your stats configuration.

Meta

CONTRIBUTING

LICENSE (Mozilla Public License)

webpack-nano's People

Contributors

bebraw avatar dependabot[bot] avatar g-rath avatar shellscape avatar trysound avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

webpack-nano's Issues

replace ts-node with sucrase-node

hi, this cli is exactly what i need, ( rather, its not everything i don't need). thank you.

Quick proposal, is to use sucrase-node as the bin for transpiling the config. I've been using it for about a month as a replacement for ts-node and let me say its beautiful. ts-node is annoying af because if you're in a web project with an es target in your tsconfig, ts-node is going to error and it makes me rage. sucrase node doesn't do that , auto supports jsx, typescript and flow. its the biz

Requested Behavior / Situation

Use sucrase-node instead of ts-node

Actual Behavior / Situation

ts-node makes me want to smash my kb

Modification Proposal

use sucrase-node

Improve webpack 5 compatibility

Feature Use Case

It looks like webpack 5 watch usage has changed. When watch mode is enabled, then webpack expects a callback to be set.

I set up a minimal demo at https://github.com/bebraw/wps-watch-demo . If you run npm start after npm install, you should see the following:

 $ npm start

> [email protected] start /Users/juhovepsalainen/Projects/github/wps-watch-demo
> node --trace-deprecation node_modules/.bin/wp --mode development

⬡ webpack: Watching Files
(node:60643) [DEP_WEBPACK_WATCH_WITHOUT_CALLBACK] DeprecationWarning: A 'callback' argument need to be provided to the 'webpack(options, callback)' function when the 'watch' option is set. There is no way to handle the 'watch' option without a callback.
    at webpack (/Users/juhovepsalainen/Projects/github/wps-watch-demo/node_modules/webpack/lib/webpack.js:145:5)
    at f (/Users/juhovepsalainen/Projects/github/wps-watch-demo/node_modules/webpack/lib/index.js:35:15)
    at run (/Users/juhovepsalainen/Projects/github/wps-watch-demo/node_modules/webpack-nano/lib/compiler.js:16:20)
    at doeet (/Users/juhovepsalainen/Projects/github/wps-watch-demo/node_modules/webpack-nano/bin/wp.js:79:3)
⬡ wps: Server Listening on: http://[::]:8080

⬡ webpack: asset main.js 73.1 KiB [emitted] [compared for emit] (name: main)
  asset index.html 198 bytes [compared for emit]
  runtime modules 25.2 KiB 11 modules
  cacheable modules 25 KiB
    modules by path ./node_modules/webpack-plugin-serve/lib/client/ 23.7 KiB
      modules by path ./node_modules/webpack-plugin-serve/lib/client/*.js 8.02 KiB 4 modules
      modules by path ./node_modules/webpack-plugin-serve/lib/client/overlays/*.js 15.7 KiB
        ./node_modules/webpack-plugin-serve/lib/client/overlays/progress-minimal.js 2.38 KiB [built] [code generated]
        ./node_modules/webpack-plugin-serve/lib/client/overlays/progress.js 3.88 KiB [built] [code generated]
        ./node_modules/webpack-plugin-serve/lib/client/overlays/status.js 8.27 KiB [built] [code generated]
        ./node_modules/webpack-plugin-serve/lib/client/overlays/util.js 1.17 KiB [built] [code generated]
    modules by path ./src/*.js 217 bytes
      ./src/index.js 77 bytes [built] [code generated]
      ./src/component.js 140 bytes [built] [code generated]
    ./node_modules/webpack-plugin-serve/client.js 1.05 KiB [built] [code generated]
  0 (webpack 5.1.0) compiled successfully in 152 ms

⬡ webpack: ⁿᵃⁿᵒ Duplicate build detected (28144bc52857f5b168c6)

That Duplicate build detected is a weird one as well and I don't know why we have it yet. It looks like it's coming from webpack-nano itself.

Feature Proposal

Likely the callback webpack 5 expects should be defined anyhow or it should be injected only if watch mode is enabled in the configuration whichever is easier.

Preserve log colors

Expected Behavior / Situation

Colors emitted in webpack logs are preserved

Actual Behavior / Situation

Colors are not preserved by webpack-nano.

Modification Proposal

It's a minor thing, but the colors make the logs easier to read:

ss 2018-12-04 at 11 17 22

vs.

ss 2018-12-04 at 11 15 28

Using babel for webpack config?

Expected Behavior / Situation

I would like to use modern JS/Babel in/for my webpack config.

export default (env = {}, argv = {}) => {
  const mode = argv.mode || process.env.NODE_ENV || "development";
  ...
  return {
    ...
  }
}

Actual Behavior / Situation

Following error shows up:

npx wp --mode development --config webpack.config.babel.js
[dotenv][DEBUG] did not match key and value when parsing line 7:
WebpackOptionsValidationError: Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration has an unknown property 'default'. These properties are valid:
   object { amd?, bail?, cache?, context?, dependencies?, devServer?, devtool?, entry?, externals?, loader?, mode?, module?, name?, node?, optimization?, output?, parallelism?, performance?, plugins?, profile?, recordsInputPath?, recordsOutputPath?, recordsPath?, resolve?, resolveLoader?, serve?, stats?, target?, watch?, watchOptions? }
   For typos: please correct them.

Modification Proposal

Is this possible?

Allow webpack.config.babel.js

First I want to say thank you so damn much for this and webpack-plugin-serve. I am brand new to webpack. Trying to convert large angularjs app from jspm. In only a couple hours I had the entire app building and loading but I was about to give up after 30 straight hours of trying to get HMR working with a server processed index.html and https proxy. The in memory of WDS just destroyed me. And right at the very end, I find you talking about being done with webpack-serve. A github profile click later and I find the webpack-plugin-serve gem. In about 10 mins I have a completed build process with great HMR. So thank you, I just became a Patreon, and i've never been more happy to.

Expected Behavior / Situation

Since I am still so new, not sure if this is possible. But i figured i'd give it a shot. Plus i wanted to thank you anyway. I can still bypass webpack-nano using npx webpack --config webpack.config.babel.js.

Allow webpack.config.babel.js either through default no config, or --config webpack.config.babel.js

Actual Behavior / Situation

First import in config from command npx wp --config webpack.config.babel.js throws SyntaxError: Unexpected identifier`.

Modification Proposal

Looking in webpack source is daunting so I'm not sure. But hopefully this package can do what npx webpack --config webpack.config.babel.js does.

Indicate when file change has been detected when watching

Feature Use Case

Let the user know that webpack-nano has noticed a change in a file under watch.

Feature Proposal

Log a message to the console whenever a change is detected in a watched file.

This is done by webpack-dev-middleware: (note the 'Compiling...' log entry)

ss 2018-12-05 at 04 35 47

Package size :)

If you wanted to increase the gap between webpack-cli and webpack-nano in size, it looks like ~50% of the package size is license file, which probably could be slimmed down :)

image

webpack-nano package.json possible fix?

  • Webpack Version: 5.6.0
  • Operating System (or Browser): Windows 10 / Firefox Developer
  • Node Version: 14.15.1
  • webpack-nano Version: Current

How Do We Reproduce?

I simply installed the latest webpack 5.6.0 then tried to install webpack-nano --save-dev and it lists the peer dependency as webpack 4.42.2 which is what I see being called in package.json, however, not sure how to get this to work

Expected Behavior

install webpack nano = no errors

Actual Behavior

doesn't install says cannot find peer dependency webpack 4.42.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.