├── .husky
├── pre-commit
└── commit-msg
├── CODEOWNERS
├── test
├── api
│ ├── test-all-lock
│ │ ├── yarn.lock
│ │ ├── pnpm-lock.yaml
│ │ └── package-lock.json
│ ├── test-yarn-lock
│ │ └── yarn.lock
│ ├── test-npm-and-yarn
│ │ ├── yarn.lock
│ │ └── package-lock.json
│ ├── test-pnpm-lock
│ │ └── pnpm-lock.yaml
│ ├── test-yarn-and-pnpm
│ │ ├── yarn.lock
│ │ └── pnpm-lock.yaml
│ ├── test-npm-and-pnpm
│ │ ├── pnpm-lock.yaml
│ │ └── package-lock.json
│ ├── test-npm-lock
│ │ └── package-lock.json
│ ├── resolve-config
│ │ ├── webpack.config1.cjs
│ │ ├── webpack.config2.cjs
│ │ ├── env.webpack.config.cjs
│ │ ├── webpack.promise.config.cjs
│ │ └── webpack.config.cjs
│ └── capitalizeFirstLetter.test.js
├── build
│ ├── entry
│ │ ├── config-entry
│ │ │ ├── a.js
│ │ │ ├── entry-with-config
│ │ │ │ ├── index.js
│ │ │ │ └── entry-with-config.test.js
│ │ │ ├── entry-with-index
│ │ │ │ ├── src
│ │ │ │ │ ├── app.js
│ │ │ │ │ ├── index.js
│ │ │ │ │ └── print.js
│ │ │ │ └── webpack.config.js
│ │ │ └── 1.js
│ │ ├── defaults-index
│ │ │ └── src
│ │ │ │ └── index.js
│ │ ├── scss
│ │ │ ├── home.js
│ │ │ ├── home.scss
│ │ │ ├── scss.test.js
│ │ │ └── webpack.config.js
│ │ ├── flag-entry
│ │ │ ├── src
│ │ │ │ ├── a.js
│ │ │ │ └── index.cjs
│ │ │ └── entry.config.js
│ │ ├── multiple-entries
│ │ │ └── src
│ │ │ │ ├── a.js
│ │ │ │ ├── b.js
│ │ │ │ └── c.js
│ │ └── defaults-empty
│ │ │ └── entry-single-arg.test.js
│ ├── import-local
│ │ ├── src
│ │ │ └── index.js
│ │ └── import-local.test.js
│ ├── config
│ │ ├── no-code
│ │ │ ├── webpack.config.js
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ └── no-code.test.js
│ │ ├── absent
│ │ │ └── a.js
│ │ ├── basic
│ │ │ ├── a.js
│ │ │ ├── webpack.config.js
│ │ │ └── basic-config.test.js
│ │ ├── empty
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── empty.test.js
│ │ ├── empty-array
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── empty-array.test.js
│ │ ├── no-config-array
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── no-config-array.test.js
│ │ ├── no-config-object
│ │ │ ├── a.js
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── no-config-object.test.js
│ │ ├── type
│ │ │ ├── array
│ │ │ │ ├── a.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── array-function-with-env
│ │ │ │ ├── a.js
│ │ │ │ ├── b.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── function-with-argv
│ │ │ │ ├── a.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── function
│ │ │ │ ├── a.js
│ │ │ │ ├── webpack.config.js
│ │ │ │ └── function.test.js
│ │ │ ├── promise
│ │ │ │ ├── a.js
│ │ │ │ ├── webpack.config.js
│ │ │ │ └── promise.test.js
│ │ │ ├── array-function-with-argv
│ │ │ │ ├── a.js
│ │ │ │ ├── b.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── array-functions
│ │ │ │ ├── a.js
│ │ │ │ ├── b.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── array-promises
│ │ │ │ ├── a.js
│ │ │ │ ├── b.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── function-array
│ │ │ │ ├── a.js
│ │ │ │ ├── b.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── function-async
│ │ │ │ ├── a.js
│ │ │ │ ├── webpack.config.js
│ │ │ │ └── function-async.test.js
│ │ │ ├── promise-array
│ │ │ │ ├── a.js
│ │ │ │ ├── b.js
│ │ │ │ ├── webpack.config.js
│ │ │ │ └── promise-array.test.js
│ │ │ ├── promise-function
│ │ │ │ ├── a.js
│ │ │ │ ├── webpack.config.js
│ │ │ │ └── promise-function.test.js
│ │ │ ├── function-promise
│ │ │ │ ├── a.js
│ │ │ │ ├── webpack.config.js
│ │ │ │ └── function-promise.test.js
│ │ │ └── function-with-env
│ │ │ │ └── a.js
│ │ ├── defaults
│ │ │ ├── with-mode
│ │ │ │ ├── index.js
│ │ │ │ ├── webpack.config.js
│ │ │ │ └── default-config-with-mode.test.js
│ │ │ ├── basic-config
│ │ │ │ ├── src
│ │ │ │ │ └── index.js
│ │ │ │ └── webpack.config.js
│ │ │ ├── cjs-config
│ │ │ │ ├── src
│ │ │ │ │ └── index.js
│ │ │ │ └── webpack.config.cjs
│ │ │ ├── mjs-config
│ │ │ │ ├── src
│ │ │ │ │ └── index.js
│ │ │ │ └── webpack.config.mjs
│ │ │ ├── dot-webpack-directory
│ │ │ │ ├── index.js
│ │ │ │ ├── .webpack
│ │ │ │ │ └── webpack.config.js
│ │ │ │ └── dot-webpack-config.test.js
│ │ │ └── dot-webpack-directory-webpackfile
│ │ │ │ ├── index.js
│ │ │ │ ├── .webpack
│ │ │ │ └── webpackfile.js
│ │ │ │ └── dot-webpack-webpackfile.test.js
│ │ ├── function
│ │ │ ├── src
│ │ │ │ ├── first.js
│ │ │ │ ├── index.js
│ │ │ │ └── second.js
│ │ │ ├── single-webpack.config.js
│ │ │ └── multi-webpack.config.js
│ │ ├── multiple
│ │ │ ├── init.js
│ │ │ ├── webpack2.config.js
│ │ │ ├── webpack1.config.js
│ │ │ └── multiple-config.test.js
│ │ ├── empty-promise
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── empty-promise.test.js
│ │ ├── error-mjs
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.mjs
│ │ │ └── syntax-error.mjs
│ │ ├── invalid-export
│ │ │ ├── webpack.config.js
│ │ │ └── invalid-export.test.js
│ │ ├── object-freeze
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── index.test.js
│ │ ├── undefined
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── undefined.test.js
│ │ ├── empty-function
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── empty-function.test.js
│ │ ├── error-array
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── config-array-error.test.js
│ │ ├── error-commonjs
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── syntax-error.js
│ │ ├── multiple-with-one-compilation
│ │ │ ├── a.js
│ │ │ ├── webpack.config.js
│ │ │ └── multiple-with-one-compilation.test.js
│ │ ├── named-export
│ │ │ ├── webpack.config.mjs
│ │ │ └── mjs.test.js
│ │ ├── undefined-default
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── undefined-default.test.js
│ │ ├── object-freeze-partial
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── index.test.js
│ │ ├── top-multi-compilers-options
│ │ │ └── index.js
│ │ └── invalid-path
│ │ │ └── invalid-path.test.js
│ ├── node
│ │ ├── a.js
│ │ ├── bootstrap.js
│ │ ├── bootstrap2.js
│ │ └── webpack.config.js
│ ├── basic
│ │ ├── src
│ │ │ ├── again.js
│ │ │ ├── entry.js
│ │ │ ├── index.js
│ │ │ └── other.js
│ │ ├── entry.config.js
│ │ └── log.config.js
│ ├── cache
│ │ ├── src
│ │ │ └── main.js
│ │ └── webpack.config.js
│ ├── colors
│ │ ├── src
│ │ │ ├── first.js
│ │ │ ├── second.js
│ │ │ └── index.js
│ │ ├── webpack.config.js
│ │ ├── no-stats.webpack.config.js
│ │ ├── stats-boolean.webpack.config.js
│ │ ├── stats-string.webpack.config.js
│ │ ├── colors-false.webpack.config.js
│ │ ├── colors-true.webpack.config.js
│ │ ├── stats-colors.webpack.config.js
│ │ ├── multiple-configs.js
│ │ └── multi-stats-colors.webpack.config.js
│ ├── devtool
│ │ ├── array
│ │ │ └── index.js
│ │ └── object
│ │ │ ├── index.js
│ │ │ ├── webpack.source.config.js
│ │ │ └── webpack.eval.config.js
│ ├── json
│ │ ├── src
│ │ │ └── index.js
│ │ └── logging.config.js
│ ├── stats
│ │ ├── config
│ │ │ ├── index.js
│ │ │ └── webpack.config.js
│ │ ├── flags
│ │ │ ├── index.js
│ │ │ ├── webpack.config.js
│ │ │ └── __snapshots__
│ │ │ │ └── stats.test.js.snap.webpack5
│ │ └── config-no
│ │ │ ├── main.js
│ │ │ └── webpack.config.js
│ ├── core-flags
│ │ ├── mock
│ │ │ └── mock.js
│ │ ├── src
│ │ │ ├── entry.js
│ │ │ ├── index.js
│ │ │ └── main.js
│ │ ├── my-warning-loader.js
│ │ ├── webpack.config.js
│ │ ├── webpack.cache.config.js
│ │ └── warning.config.js
│ ├── custom-webpack
│ │ ├── src
│ │ │ └── index.js
│ │ ├── custom-webpack.js
│ │ └── webpack.config.js
│ ├── name
│ │ ├── src
│ │ │ └── index.js
│ │ ├── webpack.config.js
│ │ └── name.test.js
│ ├── node-env
│ │ ├── src
│ │ │ └── index.js
│ │ ├── auto-mode.config.js
│ │ └── webpack.config.js
│ ├── progress
│ │ ├── src
│ │ │ └── index.js
│ │ └── webpack.progress.config.js
│ ├── config-lookup
│ │ ├── relative
│ │ │ ├── a.js
│ │ │ └── webpack.config.js
│ │ ├── custom-name
│ │ │ ├── a.js
│ │ │ ├── config.webpack.js
│ │ │ └── config.webpack.mjs
│ │ ├── dotfolder-array
│ │ │ ├── a.js
│ │ │ ├── .webpack
│ │ │ │ └── webpack.config.js
│ │ │ └── dotfolder-array.test.js
│ │ └── dotfolder-single
│ │ │ ├── index_two.js
│ │ │ ├── .webpack
│ │ │ └── webpack.config.js
│ │ │ └── dotfolder-single.test.js
│ ├── config-name
│ │ ├── src
│ │ │ ├── first.js
│ │ │ ├── third.js
│ │ │ └── second.js
│ │ ├── single-config.js
│ │ ├── single-other-config.js
│ │ ├── function-config.js
│ │ └── webpack.config.js
│ ├── defaults
│ │ ├── a.js
│ │ └── src
│ │ │ └── index.js
│ ├── error
│ │ ├── error-in-plugin
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ └── webpack.config.js
│ │ └── invalid-schema
│ │ │ ├── webpack.mock.config.js
│ │ │ └── webpack.plugin-mock.config.js
│ ├── merge
│ │ ├── config
│ │ │ ├── first-entry.js
│ │ │ ├── second-entry.js
│ │ │ ├── third-entry.js
│ │ │ ├── 3.js
│ │ │ ├── 2.js
│ │ │ └── 1.js
│ │ └── config-absent
│ │ │ ├── some_entry.js
│ │ │ └── 1.js
│ ├── target
│ │ ├── flag-test
│ │ │ ├── index.js
│ │ │ ├── webpack.config.js
│ │ │ ├── target.web.config.js
│ │ │ └── multiple-target.config.js
│ │ └── node
│ │ │ ├── new.js
│ │ │ ├── main.js
│ │ │ ├── webpack.config.js
│ │ │ ├── __snapshots__
│ │ │ └── node-test.test.js.snap.webpack5
│ │ │ └── node-test.test.js
│ ├── analyze
│ │ ├── src
│ │ │ └── index.js
│ │ ├── webpack.config.js
│ │ ├── analyze.config.js
│ │ └── analyze-flag.test.js
│ ├── build-variable
│ │ ├── src
│ │ │ └── index.js
│ │ ├── build-variable.test.js
│ │ └── webpack.config.js
│ ├── bundle-variable
│ │ ├── src
│ │ │ └── index.js
│ │ ├── bundle-variable.test.js
│ │ └── webpack.config.js
│ ├── config-format
│ │ ├── commonjs
│ │ │ ├── main.js
│ │ │ ├── webpack.config.cjs
│ │ │ └── commonjs.test.js
│ │ ├── esm
│ │ │ ├── main.js
│ │ │ ├── webpack.config.mjs
│ │ │ └── mjs.test.js
│ │ ├── coffee
│ │ │ ├── main.js
│ │ │ ├── webpack.config.coffee
│ │ │ └── coffee.test.js
│ │ ├── commonjs-default
│ │ │ ├── main.js
│ │ │ ├── webpack.config.cjs
│ │ │ └── commonjs-default.test.js
│ │ ├── esm-require
│ │ │ ├── main.js
│ │ │ └── webpack.config.js
│ │ ├── babel-commonjs
│ │ │ ├── main.js
│ │ │ ├── package.json
│ │ │ ├── webpack.config.babel.js
│ │ │ └── babel-esm.test.js
│ │ ├── esm-require-await
│ │ │ ├── main.js
│ │ │ └── webpack.config.js
│ │ ├── disable-interpret
│ │ │ ├── main.ts
│ │ │ ├── tsconfig.json
│ │ │ └── webpack.config.ts
│ │ ├── typescript-ts-node-loader
│ │ │ ├── main.ts
│ │ │ ├── package.json
│ │ │ ├── tsconfig.json
│ │ │ └── webpack.config.ts
│ │ ├── typescript-using-nodejs
│ │ │ ├── main.ts
│ │ │ ├── package.json
│ │ │ ├── tsconfig.json
│ │ │ └── webpack.config.ts
│ │ ├── typescript-cjs-using-nodejs
│ │ │ ├── main.ts
│ │ │ ├── package.json
│ │ │ ├── tsconfig.json
│ │ │ └── webpack.config.ts
│ │ ├── typescript-mjs-using-nodejs
│ │ │ ├── main.ts
│ │ │ ├── package.json
│ │ │ ├── tsconfig.json
│ │ │ └── webpack.config.ts
│ │ ├── typescript-ts-node-require
│ │ │ ├── main.ts
│ │ │ ├── tsconfig.json
│ │ │ └── webpack.config.ts
│ │ ├── failure
│ │ │ ├── webpack.config.json5
│ │ │ ├── webpack.config.iced
│ │ │ └── failure.test.js
│ │ └── babel-esm
│ │ │ └── package.json
│ ├── extends
│ │ ├── simple-case
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── override.config.js
│ │ │ ├── base.webpack.config.js
│ │ │ └── webpack.config.js
│ │ ├── extends-cli-option
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ ├── base.webpack.config.js
│ │ │ ├── deep.base.webpack.config.js
│ │ │ └── webpack.config.js
│ │ ├── multiple-extends
│ │ │ ├── src
│ │ │ │ └── index2.js
│ │ │ ├── base1.webpack.config.js
│ │ │ ├── base2.webpack.config.js
│ │ │ └── webpack.config.js
│ │ ├── multi-level-extends
│ │ │ ├── src
│ │ │ │ └── index1.js
│ │ │ ├── base2.webpack.config.js
│ │ │ ├── webpack.config.js
│ │ │ └── base1.webpack.config.js
│ │ ├── multiple-configs
│ │ │ ├── src
│ │ │ │ ├── index1.js
│ │ │ │ └── index2.js
│ │ │ ├── other.config.js
│ │ │ ├── base.webpack.config.js
│ │ │ └── webpack.config.js
│ │ ├── multiple-configs1
│ │ │ ├── src
│ │ │ │ ├── index1.js
│ │ │ │ └── index2.js
│ │ │ ├── other.config.js
│ │ │ ├── webpack.config.js
│ │ │ └── base.webpack.config.js
│ │ ├── multiple-configs2
│ │ │ ├── src
│ │ │ │ ├── index1.js
│ │ │ │ └── index2.js
│ │ │ ├── base.webpack.config.js
│ │ │ └── webpack.config.js
│ │ └── recursive-extends
│ │ │ ├── other.config.js
│ │ │ └── webpack.config.js
│ ├── mode
│ │ ├── mode-single-arg
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ └── webpack.config.js
│ │ └── mode-with-config
│ │ │ ├── webpack.config3.js
│ │ │ ├── webpack.config2.js
│ │ │ ├── src
│ │ │ └── index.js
│ │ │ └── webpack.config.js
│ ├── config-node-env
│ │ ├── src
│ │ │ └── index.js
│ │ ├── auto-mode.config.js
│ │ └── webpack.config.js
│ ├── output
│ │ ├── a.js
│ │ ├── b.js
│ │ ├── c.js
│ │ ├── webpack.defaults.config.js
│ │ ├── webpack.config.js
│ │ ├── webpack.multiple.config.js
│ │ ├── webpack.single.config.js
│ │ └── __snapshots__
│ │ │ └── output-named-bundles.test.js.snap.webpack5
│ ├── zero-config
│ │ ├── entry-present
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ └── zero-config.test.js
│ │ └── entry-absent
│ │ │ └── zero-config.test.js
│ ├── bail
│ │ ├── src
│ │ │ ├── first.js
│ │ │ └── second.js
│ │ ├── no-bail-webpack.config.js
│ │ ├── bail-webpack.config.js
│ │ ├── watch-webpack.config.js
│ │ ├── bail-and-watch-webpack.config.js
│ │ ├── bail-multi-webpack.config.js
│ │ └── multi-webpack.config.js
│ ├── start-finish-force-log
│ │ ├── src
│ │ │ └── index.js
│ │ ├── webpack.config.js
│ │ └── webpack.config.array.js
│ ├── build-errors
│ │ └── src
│ │ │ └── index.js
│ ├── env
│ │ ├── array
│ │ │ ├── src
│ │ │ │ └── index.js
│ │ │ └── webpack.config.js
│ │ └── object
│ │ │ ├── src
│ │ │ └── index.js
│ │ │ └── webpack.config.js
│ └── build-warnings
│ │ └── src
│ │ └── index.js
├── utils
│ ├── src
│ │ └── index.js
│ ├── cli-plugin-test
│ │ ├── main.js
│ │ ├── webpack.config.js
│ │ └── plugin.test.js
│ └── exec-in-directory.js
├── watch
│ ├── stats
│ │ ├── src
│ │ │ └── index.js
│ │ └── webpack.config.js
│ ├── basic
│ │ ├── basic.config.js
│ │ ├── src
│ │ │ ├── entry.js
│ │ │ └── index.js
│ │ ├── watch.config.js
│ │ ├── no-watch.config.js
│ │ └── log.config.js
│ ├── stdin
│ │ ├── src
│ │ │ ├── index.js
│ │ │ └── second.js
│ │ ├── serve.config.js
│ │ ├── watch.config.js
│ │ ├── multi-serve.config.js
│ │ └── multi-watch.config.js
│ ├── analyze
│ │ ├── src
│ │ │ └── index.js
│ │ ├── webpack.config.js
│ │ ├── analyze.config.js
│ │ └── analyze-flag.test.js
│ ├── watch-variable
│ │ ├── src
│ │ │ └── index.js
│ │ └── webpack.config.js
│ └── bail
│ │ ├── src
│ │ ├── first.js
│ │ └── second.js
│ │ ├── no-bail-webpack.config.js
│ │ ├── bail-webpack.config.js
│ │ ├── watch-webpack.config.js
│ │ ├── bail-and-watch-webpack.config.js
│ │ ├── bail-multi-webpack.config.js
│ │ └── multi-webpack.config.js
├── serve
│ ├── basic
│ │ ├── src
│ │ │ ├── entry.js
│ │ │ ├── other.js
│ │ │ ├── worker.js
│ │ │ └── index.js
│ │ ├── dev-server-false.config.js
│ │ ├── log.config.js
│ │ ├── helper
│ │ │ └── base-dev-server.config.js
│ │ ├── stats.config.js
│ │ ├── serve.config.js
│ │ ├── webpack.config.js
│ │ ├── watch.config.js
│ │ ├── output-public-path.config.js
│ │ ├── function-with-env.config.js
│ │ ├── function-with-argv.config.js
│ │ ├── dev-server-output-public-path.config.js
│ │ ├── same-ports-dev-server.config.js
│ │ ├── dev-server-false.multi.config.js
│ │ └── multi.config.js
│ ├── serve-variable
│ │ ├── src
│ │ │ └── index.js
│ │ ├── __snapshots__
│ │ │ └── serve-variable.test.js.snap.devServer5.webpack5
│ │ └── webpack.config.js
│ ├── with-custom-port
│ │ ├── src
│ │ │ └── index.js
│ │ └── webpack.config.js
│ └── invalid-schema
│ │ ├── webpack.config.mock.js
│ │ └── webpack-dev-server.config.mock.js
├── configtest
│ ├── with-config-path
│ │ ├── src
│ │ │ └── index.js
│ │ ├── basic.config.js
│ │ ├── error.config.js
│ │ └── syntax-error.config.js
│ ├── without-config-path-error
│ │ ├── webpack.config.js
│ │ └── without-config-path-error.test.js
│ ├── without-config-path
│ │ ├── webpack.config.js
│ │ ├── __snapshots__
│ │ │ └── without-config-path.test.js.snap.webpack5
│ │ └── without-config-path.test.js
│ ├── without-config-path-custom-extension
│ │ ├── webpack.config.json
│ │ ├── without-config-path.test.js
│ │ └── __snapshots__
│ │ │ └── without-config-path.test.js.snap.webpack5
│ ├── without-config-path-multi-compiler-mode
│ │ ├── webpack.config.js
│ │ ├── without-config-path-multi-compiler-mode.test.js
│ │ └── __snapshots__
│ │ │ └── without-config-path-multi-compiler-mode.test.js.snap.webpack5
│ └── without-config-path-no-configuration
│ │ ├── __snapshots__
│ │ └── without-config-path-no-configuration.test.js.snap.webpack5
│ │ └── without-config-path-no-configuration.test.js
└── create-webpack-app
│ └── loader
│ ├── warning-test
│ ├── src
│ │ └── main.js
│ ├── my-loader.js
│ └── loader-warning.test.js
│ └── error-test
│ ├── src
│ └── index.ts
│ ├── tsconfig.json
│ └── webpack.config.js
├── .gitattributes
├── packages
├── create-webpack-app
│ ├── bin
│ │ └── cli.js
│ ├── templates
│ │ ├── init
│ │ │ ├── vue
│ │ │ │ ├── src
│ │ │ │ │ ├── App.vue.tpl
│ │ │ │ │ ├── assets
│ │ │ │ │ │ └── webpack.png.tpl
│ │ │ │ │ ├── components
│ │ │ │ │ │ └── Layout.vue.tpl
│ │ │ │ │ └── store
│ │ │ │ │ │ └── index.js.tpl
│ │ │ │ ├── README.md.tpl
│ │ │ │ ├── index.html.tpl
│ │ │ │ └── package.json.tpl
│ │ │ ├── default
│ │ │ │ ├── src
│ │ │ │ │ ├── index.js.tpl
│ │ │ │ │ └── index.ts.tpl
│ │ │ │ ├── babel.config.json.tpl
│ │ │ │ ├── postcss.config.js.tpl
│ │ │ │ ├── tsconfig.json.tpl
│ │ │ │ ├── README.md.tpl
│ │ │ │ └── package.json.tpl
│ │ │ ├── svelte
│ │ │ │ ├── src
│ │ │ │ │ ├── index.d.ts.tpl
│ │ │ │ │ ├── assets
│ │ │ │ │ │ └── webpack.png.tpl
│ │ │ │ │ ├── styles
│ │ │ │ │ │ ├── global.less.tpl
│ │ │ │ │ │ ├── global.scss.tpl
│ │ │ │ │ │ ├── global.styl.tpl
│ │ │ │ │ │ └── global.css.tpl
│ │ │ │ │ ├── main.js.tpl
│ │ │ │ │ ├── main.ts.tpl
│ │ │ │ │ └── components
│ │ │ │ │ │ └── HelloWorld.svelte.tpl
│ │ │ │ ├── README.md.tpl
│ │ │ │ ├── index.html.tpl
│ │ │ │ ├── package.json.tpl
│ │ │ │ └── tsconfig.json.tpl
│ │ │ └── react
│ │ │ │ ├── src
│ │ │ │ ├── assets
│ │ │ │ │ └── webpack.png.tpl
│ │ │ │ ├── App.jsx.tpl
│ │ │ │ ├── App.tsx.tpl
│ │ │ │ ├── components
│ │ │ │ │ ├── About.jsx.tpl
│ │ │ │ │ └── About.tsx.tpl
│ │ │ │ ├── index.jsx.tpl
│ │ │ │ ├── index.tsx.tpl
│ │ │ │ └── router
│ │ │ │ │ ├── index.jsx.tpl
│ │ │ │ │ └── index.tsx.tpl
│ │ │ │ ├── index.d.ts.tpl
│ │ │ │ ├── README.md.tpl
│ │ │ │ ├── package.json.tpl
│ │ │ │ ├── index.html.tpl
│ │ │ │ └── tsconfig.json.tpl
│ │ ├── loader
│ │ │ └── default
│ │ │ │ ├── examples
│ │ │ │ └── simple
│ │ │ │ │ ├── src
│ │ │ │ │ ├── lazy-module.js.tpl
│ │ │ │ │ ├── static-esm-module.js.tpl
│ │ │ │ │ └── index.js.tpl
│ │ │ │ │ └── webpack.config.js.tpl
│ │ │ │ ├── src
│ │ │ │ └── cjs.js.tpl
│ │ │ │ ├── test
│ │ │ │ └── fixtures
│ │ │ │ │ └── simple-file.js.tpl
│ │ │ │ └── package.json.tpl
│ │ └── plugin
│ │ │ └── default
│ │ │ ├── examples
│ │ │ └── simple
│ │ │ │ ├── src
│ │ │ │ ├── lazy-module.js.tpl
│ │ │ │ ├── static-esm-module.js.tpl
│ │ │ │ └── index.js.tpl
│ │ │ │ └── webpack.config.js.tpl
│ │ │ ├── src
│ │ │ ├── cjs.js.tpl
│ │ │ └── index.js.tpl
│ │ │ ├── test
│ │ │ ├── fixtures
│ │ │ │ └── simple-file.js.tpl
│ │ │ └── functional.test.js.tpl
│ │ │ └── package.json.tpl
│ ├── tsconfig.json
│ └── src
│ │ └── plopfile.ts
├── webpack-cli
│ ├── tsconfig.json
│ ├── src
│ │ ├── index.ts
│ │ ├── utils
│ │ │ └── dynamic-import-loader.ts
│ │ └── bootstrap.ts
│ └── bin
│ │ └── cli.js
├── info
│ ├── tsconfig.json
│ └── src
│ │ └── index.ts
├── serve
│ └── tsconfig.json
└── configtest
│ ├── tsconfig.json
│ ├── README.md
│ └── package.json
├── prettier.config.js
├── .devcontainer
├── Dockerfile
└── devcontainer.json
├── .nycrc
├── scripts
├── global-setup.js
├── setup-test.js
└── setup-build.js
├── lint-staged.config.js
├── commitlint.config.js
├── .editorconfig
├── lerna.json
├── .codecov.yml
├── CODE_OF_CONDUCT.md
├── .prettierignore
├── .github
├── workflows
│ └── dependency-review.yml
└── dependabot.yml
└── smoketests
└── missing-packages
└── webpack-bundle-analyzer.test.js
/.husky/pre-commit:
--------------------------------------------------------------------------------
1 | lint-staged
2 |
--------------------------------------------------------------------------------
/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @webpack/cli-team
--------------------------------------------------------------------------------
/test/api/test-all-lock/yarn.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-yarn-lock/yarn.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-all-lock/pnpm-lock.yaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-npm-and-yarn/yarn.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-pnpm-lock/pnpm-lock.yaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-yarn-and-pnpm/yarn.lock:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/build/entry/config-entry/a.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/build/import-local/src/index.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.husky/commit-msg:
--------------------------------------------------------------------------------
1 | commitlint --edit $1
2 |
--------------------------------------------------------------------------------
/test/api/test-all-lock/package-lock.json:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-npm-and-pnpm/pnpm-lock.yaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-npm-lock/package-lock.json:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-yarn-and-pnpm/pnpm-lock.yaml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/build/config/no-code/webpack.config.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | * text eol=lf
2 | *png.tpl -text
--------------------------------------------------------------------------------
/test/api/test-npm-and-pnpm/package-lock.json:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/api/test-npm-and-yarn/package-lock.json:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/build/entry/defaults-index/src/index.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/utils/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('Yukii')
2 |
--------------------------------------------------------------------------------
/test/build/node/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a.js";
2 |
--------------------------------------------------------------------------------
/test/watch/stats/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('TEST');
--------------------------------------------------------------------------------
/test/build/basic/src/again.js:
--------------------------------------------------------------------------------
1 | console.log("again");
2 |
--------------------------------------------------------------------------------
/test/build/basic/src/entry.js:
--------------------------------------------------------------------------------
1 | console.log("CONFIG");
2 |
--------------------------------------------------------------------------------
/test/build/cache/src/main.js:
--------------------------------------------------------------------------------
1 | console.log("the cache");
2 |
--------------------------------------------------------------------------------
/test/build/colors/src/first.js:
--------------------------------------------------------------------------------
1 | console.log("first");
2 |
--------------------------------------------------------------------------------
/test/build/colors/src/second.js:
--------------------------------------------------------------------------------
1 | console.log("second");
2 |
--------------------------------------------------------------------------------
/test/build/config/absent/a.js:
--------------------------------------------------------------------------------
1 | console.log("Zenitsu");
2 |
--------------------------------------------------------------------------------
/test/build/config/basic/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a.js";
2 |
--------------------------------------------------------------------------------
/test/build/devtool/array/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 'index';
--------------------------------------------------------------------------------
/test/build/entry/config-entry/entry-with-config/index.js:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/test/build/entry/scss/home.js:
--------------------------------------------------------------------------------
1 | console.log("home");
2 |
--------------------------------------------------------------------------------
/test/build/json/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 'index';
2 |
--------------------------------------------------------------------------------
/test/build/stats/config/index.js:
--------------------------------------------------------------------------------
1 | console.log('HERE');
2 |
--------------------------------------------------------------------------------
/test/build/stats/flags/index.js:
--------------------------------------------------------------------------------
1 | console.log('HERE');
2 |
--------------------------------------------------------------------------------
/test/serve/basic/src/entry.js:
--------------------------------------------------------------------------------
1 | console.log("Entry");
2 |
--------------------------------------------------------------------------------
/test/serve/basic/src/other.js:
--------------------------------------------------------------------------------
1 | console.log("HERE");
2 |
--------------------------------------------------------------------------------
/test/serve/basic/src/worker.js:
--------------------------------------------------------------------------------
1 | console.log("Worker");
2 |
--------------------------------------------------------------------------------
/test/watch/basic/basic.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {};
2 |
--------------------------------------------------------------------------------
/test/build/basic/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('hello world');
2 |
--------------------------------------------------------------------------------
/test/build/basic/src/other.js:
--------------------------------------------------------------------------------
1 | console.log("hello world");
2 |
--------------------------------------------------------------------------------
/test/build/config/empty/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 'empty';
--------------------------------------------------------------------------------
/test/build/core-flags/mock/mock.js:
--------------------------------------------------------------------------------
1 | console.log("MOCK");
2 |
--------------------------------------------------------------------------------
/test/build/custom-webpack/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('hi');
2 |
--------------------------------------------------------------------------------
/test/build/devtool/object/index.js:
--------------------------------------------------------------------------------
1 | module.exports = "index";
--------------------------------------------------------------------------------
/test/build/name/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Tensa Zangetsu")
2 |
--------------------------------------------------------------------------------
/test/build/node-env/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('--node-env test');
--------------------------------------------------------------------------------
/test/build/progress/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Jotaro Kujo")
2 |
--------------------------------------------------------------------------------
/test/serve/basic/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('hello world');
2 |
--------------------------------------------------------------------------------
/test/watch/stdin/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('watch flag test');
--------------------------------------------------------------------------------
/test/build/config-lookup/relative/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a.js";
2 |
--------------------------------------------------------------------------------
/test/build/config-name/src/first.js:
--------------------------------------------------------------------------------
1 | console.log("first config");
2 |
--------------------------------------------------------------------------------
/test/build/config-name/src/third.js:
--------------------------------------------------------------------------------
1 | console.log("third config");
2 |
--------------------------------------------------------------------------------
/test/build/config/empty-array/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 'empty';
--------------------------------------------------------------------------------
/test/build/config/empty/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {};
2 |
--------------------------------------------------------------------------------
/test/build/config/no-code/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Peeves");
2 |
--------------------------------------------------------------------------------
/test/build/config/no-config-array/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 1;
--------------------------------------------------------------------------------
/test/build/config/no-config-object/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a.js";
2 |
--------------------------------------------------------------------------------
/test/build/config/no-config-object/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 1;
--------------------------------------------------------------------------------
/test/build/config/type/array/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-array";
2 |
--------------------------------------------------------------------------------
/test/build/core-flags/src/entry.js:
--------------------------------------------------------------------------------
1 | console.log("another-entry");
2 |
--------------------------------------------------------------------------------
/test/build/defaults/a.js:
--------------------------------------------------------------------------------
1 | module.export = "output-flag-test";
2 |
--------------------------------------------------------------------------------
/test/build/error/error-in-plugin/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 'foo';
--------------------------------------------------------------------------------
/test/build/merge/config/first-entry.js:
--------------------------------------------------------------------------------
1 | console.log("first");
2 |
--------------------------------------------------------------------------------
/test/build/merge/config/second-entry.js:
--------------------------------------------------------------------------------
1 | console.log("second");
2 |
--------------------------------------------------------------------------------
/test/build/merge/config/third-entry.js:
--------------------------------------------------------------------------------
1 | console.log("third");
2 |
--------------------------------------------------------------------------------
/test/build/target/flag-test/index.js:
--------------------------------------------------------------------------------
1 | console.log("target test");
2 |
--------------------------------------------------------------------------------
/test/utils/cli-plugin-test/main.js:
--------------------------------------------------------------------------------
1 | console.log("Hello World");
2 |
--------------------------------------------------------------------------------
/test/watch/basic/src/entry.js:
--------------------------------------------------------------------------------
1 | console.log("watch flag test");
2 |
--------------------------------------------------------------------------------
/test/watch/basic/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('watch flag test');
2 |
--------------------------------------------------------------------------------
/test/watch/stdin/src/second.js:
--------------------------------------------------------------------------------
1 | console.log("watch flag test");
2 |
--------------------------------------------------------------------------------
/test/build/analyze/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('analyze flag test');
2 |
--------------------------------------------------------------------------------
/test/build/build-variable/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('hello world');
2 |
--------------------------------------------------------------------------------
/test/build/bundle-variable/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('hello world');
2 |
--------------------------------------------------------------------------------
/test/build/config-format/commonjs/main.js:
--------------------------------------------------------------------------------
1 | console.log("Hoshiumi");
2 |
--------------------------------------------------------------------------------
/test/build/config-format/esm/main.js:
--------------------------------------------------------------------------------
1 | console.log("You know who");
2 |
--------------------------------------------------------------------------------
/test/build/config-lookup/custom-name/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "foo";
2 |
--------------------------------------------------------------------------------
/test/build/config-lookup/dotfolder-array/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "hay";
2 |
--------------------------------------------------------------------------------
/test/build/config-name/src/second.js:
--------------------------------------------------------------------------------
1 | console.log("second config");
2 |
--------------------------------------------------------------------------------
/test/build/config/defaults/with-mode/index.js:
--------------------------------------------------------------------------------
1 | console.log("Iwaizumi")
2 |
--------------------------------------------------------------------------------
/test/build/config/function/src/first.js:
--------------------------------------------------------------------------------
1 | console.log("first entry");
2 |
--------------------------------------------------------------------------------
/test/build/config/function/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('default index');
2 |
--------------------------------------------------------------------------------
/test/build/config/function/src/second.js:
--------------------------------------------------------------------------------
1 | console.log("second entry");
2 |
--------------------------------------------------------------------------------
/test/build/config/multiple/init.js:
--------------------------------------------------------------------------------
1 | console.log("Monkey D Luffy");
2 |
--------------------------------------------------------------------------------
/test/build/config/type/array-function-with-env/a.js:
--------------------------------------------------------------------------------
1 | console.log("a");
2 |
--------------------------------------------------------------------------------
/test/build/config/type/array-function-with-env/b.js:
--------------------------------------------------------------------------------
1 | console.log("b");
2 |
--------------------------------------------------------------------------------
/test/build/config/type/function-with-argv/a.js:
--------------------------------------------------------------------------------
1 | console.log("Dio");
2 |
--------------------------------------------------------------------------------
/test/build/config/type/function/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-function";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/promise/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-promise";
2 |
--------------------------------------------------------------------------------
/test/build/core-flags/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Mizuhara Chizuru")
2 |
--------------------------------------------------------------------------------
/test/build/core-flags/src/main.js:
--------------------------------------------------------------------------------
1 | console.log("core-flags tests");
2 |
--------------------------------------------------------------------------------
/test/build/defaults/src/index.js:
--------------------------------------------------------------------------------
1 | module.export = 'output-flag-test';
2 |
--------------------------------------------------------------------------------
/test/build/entry/flag-entry/src/a.js:
--------------------------------------------------------------------------------
1 | console.log("Hello from a.js");
2 |
--------------------------------------------------------------------------------
/test/build/extends/simple-case/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("index.js")
2 |
--------------------------------------------------------------------------------
/test/build/merge/config-absent/some_entry.js:
--------------------------------------------------------------------------------
1 | console.log("Oikawa");
2 |
--------------------------------------------------------------------------------
/test/build/mode/mode-single-arg/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('test');
2 |
--------------------------------------------------------------------------------
/test/build/node/bootstrap.js:
--------------------------------------------------------------------------------
1 | console.log("---from bootstrap.js---");
2 |
--------------------------------------------------------------------------------
/test/serve/serve-variable/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('hello world');
2 |
--------------------------------------------------------------------------------
/test/watch/analyze/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('analyze flag test');
2 |
--------------------------------------------------------------------------------
/test/watch/watch-variable/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('watch flag test');
--------------------------------------------------------------------------------
/test/build/config-format/coffee/main.js:
--------------------------------------------------------------------------------
1 | console.log("Sakusa Kiyoomi");
2 |
--------------------------------------------------------------------------------
/test/build/config-format/commonjs-default/main.js:
--------------------------------------------------------------------------------
1 | console.log("Hoshiumi");
2 |
--------------------------------------------------------------------------------
/test/build/config-format/esm-require/main.js:
--------------------------------------------------------------------------------
1 | console.log("You know who");
2 |
--------------------------------------------------------------------------------
/test/build/config-node-env/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('--config-node-env test');
--------------------------------------------------------------------------------
/test/build/config/defaults/basic-config/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Naruto")
2 |
--------------------------------------------------------------------------------
/test/build/config/empty-array/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [{}, {}];
2 |
--------------------------------------------------------------------------------
/test/build/config/empty-promise/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 'empty-promise';
--------------------------------------------------------------------------------
/test/build/config/error-mjs/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('config error test');
2 |
--------------------------------------------------------------------------------
/test/build/config/invalid-export/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = "foo";
2 |
--------------------------------------------------------------------------------
/test/build/config/no-config-array/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [];
2 |
--------------------------------------------------------------------------------
/test/build/config/no-config-object/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {};
2 |
--------------------------------------------------------------------------------
/test/build/config/object-freeze/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Percy Weasley");
2 |
--------------------------------------------------------------------------------
/test/build/config/type/array-function-with-argv/a.js:
--------------------------------------------------------------------------------
1 | console.log("a");
2 |
--------------------------------------------------------------------------------
/test/build/config/type/array-function-with-argv/b.js:
--------------------------------------------------------------------------------
1 | console.log("b");
2 |
--------------------------------------------------------------------------------
/test/build/config/type/array-functions/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-function";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/array-functions/b.js:
--------------------------------------------------------------------------------
1 | module.exports = "b-function";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/array-promises/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-promise";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/array-promises/b.js:
--------------------------------------------------------------------------------
1 | module.exports = "b-promise";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/function-array/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-function";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/function-array/b.js:
--------------------------------------------------------------------------------
1 | module.exports = "b-function";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/function-async/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-function";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/promise-array/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-promise";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/promise-array/b.js:
--------------------------------------------------------------------------------
1 | module.exports = "b-promise";
2 |
--------------------------------------------------------------------------------
/test/build/config/type/promise-function/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-promise";
2 |
--------------------------------------------------------------------------------
/test/build/config/undefined/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Percy Weasley");
2 |
--------------------------------------------------------------------------------
/test/build/config/undefined/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = undefined;
2 |
--------------------------------------------------------------------------------
/test/build/entry/multiple-entries/src/a.js:
--------------------------------------------------------------------------------
1 | console.log("Hello from a.js");
2 |
--------------------------------------------------------------------------------
/test/build/entry/multiple-entries/src/b.js:
--------------------------------------------------------------------------------
1 | console.log("Hello from b.js");
2 |
--------------------------------------------------------------------------------
/test/build/entry/multiple-entries/src/c.js:
--------------------------------------------------------------------------------
1 | console.log("Hello from c.js");
2 |
--------------------------------------------------------------------------------
/test/build/node/bootstrap2.js:
--------------------------------------------------------------------------------
1 | console.log("---from bootstrap2.js---");
2 |
--------------------------------------------------------------------------------
/test/build/output/a.js:
--------------------------------------------------------------------------------
1 | module.export = "output-flag-test-overwrite-a.js";
2 |
--------------------------------------------------------------------------------
/test/build/output/b.js:
--------------------------------------------------------------------------------
1 | module.export = "output-flag-test-overwrite-b.js";
2 |
--------------------------------------------------------------------------------
/test/build/output/c.js:
--------------------------------------------------------------------------------
1 | module.export = "output-flag-test-overwrite-c.js";
2 |
--------------------------------------------------------------------------------
/test/build/zero-config/entry-present/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Shoyo")
2 |
--------------------------------------------------------------------------------
/test/serve/with-custom-port/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('Kageyama Tobio');
2 |
--------------------------------------------------------------------------------
/test/build/bail/src/first.js:
--------------------------------------------------------------------------------
1 | console.log("bail and watch warning test first");
2 |
--------------------------------------------------------------------------------
/test/build/colors/src/index.js:
--------------------------------------------------------------------------------
1 | const foo = 'bar';
2 |
3 | export default foo
4 |
--------------------------------------------------------------------------------
/test/build/config-format/babel-commonjs/main.js:
--------------------------------------------------------------------------------
1 | console.log("You know who");
2 |
--------------------------------------------------------------------------------
/test/build/config-format/esm-require-await/main.js:
--------------------------------------------------------------------------------
1 | console.log("You know who");
2 |
--------------------------------------------------------------------------------
/test/build/config-lookup/dotfolder-single/index_two.js:
--------------------------------------------------------------------------------
1 | module.exports = "hay";
2 |
--------------------------------------------------------------------------------
/test/build/config/defaults/cjs-config/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Jotaro Kujo")
2 |
--------------------------------------------------------------------------------
/test/build/config/defaults/mjs-config/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Jotaro Kujo")
2 |
--------------------------------------------------------------------------------
/test/build/config/empty-function/src/index.js:
--------------------------------------------------------------------------------
1 | module.exports = 'empty-function';
--------------------------------------------------------------------------------
/test/build/config/empty-function/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => ({});
2 |
--------------------------------------------------------------------------------
/test/build/config/error-array/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('Tartaglia Childe');
2 |
--------------------------------------------------------------------------------
/test/build/config/error-commonjs/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('config error test');
2 |
--------------------------------------------------------------------------------
/test/build/config/multiple-with-one-compilation/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a.js";
2 |
--------------------------------------------------------------------------------
/test/build/config/named-export/webpack.config.mjs:
--------------------------------------------------------------------------------
1 | export const config = {};
2 |
--------------------------------------------------------------------------------
/test/build/config/type/function-promise/a.js:
--------------------------------------------------------------------------------
1 | module.exports = "a-function";
2 |
--------------------------------------------------------------------------------
/test/build/config/undefined-default/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Tom Riddle");
2 |
--------------------------------------------------------------------------------
/test/build/entry/config-entry/entry-with-index/src/app.js:
--------------------------------------------------------------------------------
1 | console.log("app");
2 |
--------------------------------------------------------------------------------
/test/build/entry/flag-entry/src/index.cjs:
--------------------------------------------------------------------------------
1 | console.log("Hello from index.cjs");
2 |
--------------------------------------------------------------------------------
/test/build/extends/extends-cli-option/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("i am index.js")
2 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-extends/src/index2.js:
--------------------------------------------------------------------------------
1 | console.log("i am index2");
2 |
--------------------------------------------------------------------------------
/test/build/start-finish-force-log/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Itadori Yuuji")
2 |
--------------------------------------------------------------------------------
/test/build/stats/config-no/main.js:
--------------------------------------------------------------------------------
1 | console.log("--no-stats with config test");
2 |
--------------------------------------------------------------------------------
/test/watch/bail/src/first.js:
--------------------------------------------------------------------------------
1 | console.log("bail and watch warning test first");
2 |
--------------------------------------------------------------------------------
/test/watch/basic/watch.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | watch: true,
3 | };
4 |
--------------------------------------------------------------------------------
/test/build/bail/src/second.js:
--------------------------------------------------------------------------------
1 | console.log("bail and watch warning test second");
2 |
--------------------------------------------------------------------------------
/test/build/config/defaults/dot-webpack-directory/index.js:
--------------------------------------------------------------------------------
1 | console.log("Kageyama")
2 |
--------------------------------------------------------------------------------
/test/build/config/object-freeze-partial/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Percy Weasley");
2 |
--------------------------------------------------------------------------------
/test/build/custom-webpack/custom-webpack.js:
--------------------------------------------------------------------------------
1 | module.exports = require("webpack");
2 |
--------------------------------------------------------------------------------
/test/build/entry/config-entry/entry-with-index/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('index')
2 |
--------------------------------------------------------------------------------
/test/build/entry/config-entry/entry-with-index/src/print.js:
--------------------------------------------------------------------------------
1 | console.log("print");
2 |
--------------------------------------------------------------------------------
/test/build/extends/multi-level-extends/src/index1.js:
--------------------------------------------------------------------------------
1 | console.log("i am index1");
2 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs/src/index1.js:
--------------------------------------------------------------------------------
1 | console.log("i am index1.js");
2 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs/src/index2.js:
--------------------------------------------------------------------------------
1 | console.log("i am index2.js");
2 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs1/src/index1.js:
--------------------------------------------------------------------------------
1 | console.log("i am index1.js");
2 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs1/src/index2.js:
--------------------------------------------------------------------------------
1 | console.log("i am index2.js");
2 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs2/src/index1.js:
--------------------------------------------------------------------------------
1 | console.log("i am index1.js");
2 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs2/src/index2.js:
--------------------------------------------------------------------------------
1 | console.log("i am index2.js");
2 |
--------------------------------------------------------------------------------
/test/configtest/with-config-path/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('configtest command');
2 |
--------------------------------------------------------------------------------
/test/watch/bail/src/second.js:
--------------------------------------------------------------------------------
1 | console.log("bail and watch warning test second");
2 |
--------------------------------------------------------------------------------
/test/watch/basic/no-watch.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | watch: false,
3 | };
4 |
--------------------------------------------------------------------------------
/test/build/colors/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | };
4 |
--------------------------------------------------------------------------------
/test/build/config-format/disable-interpret/main.ts:
--------------------------------------------------------------------------------
1 | console.log("Main typescript file");
2 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-ts-node-loader/main.ts:
--------------------------------------------------------------------------------
1 | console.log("Rimuru Tempest");
2 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-using-nodejs/main.ts:
--------------------------------------------------------------------------------
1 | console.log("Rimuru Tempest");
2 |
--------------------------------------------------------------------------------
/test/build/config/object-freeze/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = Object.freeze({});
2 |
--------------------------------------------------------------------------------
/test/build/config/undefined-default/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports.default = undefined;
2 |
--------------------------------------------------------------------------------
/test/build/target/node/new.js:
--------------------------------------------------------------------------------
1 | const url = require("node:url");
2 |
3 | console.log(url);
4 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/bin/cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | import "../lib/index.js";
4 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-cjs-using-nodejs/main.ts:
--------------------------------------------------------------------------------
1 | console.log("Rimuru Tempest");
2 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-mjs-using-nodejs/main.ts:
--------------------------------------------------------------------------------
1 | console.log("Rimuru Tempest");
2 |
--------------------------------------------------------------------------------
/test/build/config/defaults/dot-webpack-directory-webpackfile/index.js:
--------------------------------------------------------------------------------
1 | console.log("Tanjiro")
2 |
--------------------------------------------------------------------------------
/test/build/merge/config-absent/1.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: "./some_entry.js",
3 | };
4 |
--------------------------------------------------------------------------------
/test/build/target/node/main.js:
--------------------------------------------------------------------------------
1 | const url = require("node:url");
2 |
3 | console.log(url);
4 |
--------------------------------------------------------------------------------
/prettier.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | printWidth: 100,
3 | trailingComma: "all",
4 | };
5 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-ts-node-require/main.ts:
--------------------------------------------------------------------------------
1 | console.log("Main typescript file");
2 |
--------------------------------------------------------------------------------
/test/build/custom-webpack/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "production",
3 | };
4 |
--------------------------------------------------------------------------------
/test/build/start-finish-force-log/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | };
4 |
--------------------------------------------------------------------------------
/test/serve/invalid-schema/webpack.config.mock.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "Nishinoya Yuu",
3 | };
4 |
--------------------------------------------------------------------------------
/test/build/analyze/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | plugins: [],
4 | };
5 |
--------------------------------------------------------------------------------
/test/build/build-errors/src/index.js:
--------------------------------------------------------------------------------
1 | import unknown from './unknown.mjs';
2 |
3 | export default unknown
4 |
--------------------------------------------------------------------------------
/test/build/error/invalid-schema/webpack.mock.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "Nishinoya Yuu",
3 | };
4 |
--------------------------------------------------------------------------------
/test/watch/analyze/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | plugins: [],
4 | };
5 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/vue/src/App.vue.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/loader/default/examples/simple/src/lazy-module.js.tpl:
--------------------------------------------------------------------------------
1 | export default 'lazy';
2 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/loader/default/src/cjs.js.tpl:
--------------------------------------------------------------------------------
1 | module.exports = require('./index').default;
2 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/examples/simple/src/lazy-module.js.tpl:
--------------------------------------------------------------------------------
1 | export default 'lazy';
2 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/src/cjs.js.tpl:
--------------------------------------------------------------------------------
1 | module.exports = require('./index').default;
2 |
--------------------------------------------------------------------------------
/test/build/config-format/failure/webpack.config.json5:
--------------------------------------------------------------------------------
1 | {
2 | mode: "development",
3 | entry: "./main.js",
4 | }
5 |
--------------------------------------------------------------------------------
/test/watch/stdin/serve.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | watchOptions: {
3 | stdin: true,
4 | },
5 | };
6 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/default/src/index.js.tpl:
--------------------------------------------------------------------------------
1 | console.log("Hello This is a Javascript project.");
2 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/default/src/index.ts.tpl:
--------------------------------------------------------------------------------
1 | console.log("Hello This is a Typescript project.");
2 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/loader/default/examples/simple/src/static-esm-module.js.tpl:
--------------------------------------------------------------------------------
1 | export default 'foo';
2 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/examples/simple/src/static-esm-module.js.tpl:
--------------------------------------------------------------------------------
1 | export default 'foo';
2 |
--------------------------------------------------------------------------------
/test/build/basic/entry.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | entry: "./src/entry.js",
4 | };
5 |
--------------------------------------------------------------------------------
/test/build/colors/no-stats.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "test",
3 | mode: "development",
4 | };
5 |
--------------------------------------------------------------------------------
/test/build/config-format/babel-commonjs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "engines": {
3 | "node": ">=18.12.0"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/build/entry/scss/home.scss:
--------------------------------------------------------------------------------
1 | body {
2 | font-size: 100%;
3 | body {
4 | background-color: red;
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/build/env/array/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('environment is '.concat(PRODUCTION ? 'production' : 'development'));
2 |
--------------------------------------------------------------------------------
/test/build/env/object/src/index.js:
--------------------------------------------------------------------------------
1 | console.log('environment is '.concat(PRODUCTION ? 'production' : 'development'));
2 |
--------------------------------------------------------------------------------
/test/build/colors/stats-boolean.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stats: true,
3 | mode: "development",
4 | };
5 |
--------------------------------------------------------------------------------
/test/build/config/empty-promise/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = new Promise((resolve) => {
2 | resolve({});
3 | });
4 |
--------------------------------------------------------------------------------
/test/create-webpack-app/loader/warning-test/src/main.js:
--------------------------------------------------------------------------------
1 | require("../my-loader");
2 | console.log("loader warning test");
3 |
--------------------------------------------------------------------------------
/test/build/colors/stats-string.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stats: "verbose",
3 | mode: "development",
4 | };
5 |
--------------------------------------------------------------------------------
/test/build/config-format/disable-interpret/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/test/build/config-lookup/dotfolder-single/.webpack/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: "./index_two.js",
3 | };
4 |
--------------------------------------------------------------------------------
/test/watch/stdin/watch.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | watch: true,
3 | watchOptions: {
4 | stdin: true,
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/config-format/babel-esm/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "engines": {
4 | "node": ">=18.12.0"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-ts-node-require/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "commonjs"
4 | }
5 | }
6 |
--------------------------------------------------------------------------------
/.devcontainer/Dockerfile:
--------------------------------------------------------------------------------
1 | FROM node:lts
2 |
3 | # Add global instances of prettier and eslint for vscode
4 | RUN npm install -g eslint prettier
5 |
--------------------------------------------------------------------------------
/test/build/target/node/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: "./main.js",
3 | mode: "development",
4 | target: "node",
5 | };
6 |
--------------------------------------------------------------------------------
/test/create-webpack-app/loader/error-test/src/index.ts:
--------------------------------------------------------------------------------
1 | const foobar = "foobar";
2 |
3 | foobar = "barbaz"; // Error!
4 | console.log(foobar);
5 |
--------------------------------------------------------------------------------
/test/serve/basic/dev-server-false.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | devtool: false,
4 | devServer: false,
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/bail/no-bail-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: false,
3 | entry: "./src/first.js",
4 | mode: "development",
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/basic/log.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | infrastructureLogging: {
4 | level: "log",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/colors/colors-false.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stats: {
3 | colors: false,
4 | },
5 | mode: "development",
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/colors/colors-true.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stats: {
3 | colors: true,
4 | },
5 | mode: "development",
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-using-nodejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "engines": {
4 | "node": ">=18.12.0"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/build/json/logging.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | infrastructureLogging: {
4 | level: "log",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/merge/config/3.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: "./third-entry.js",
3 | output: {
4 | filename: "third-output.js",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/configtest/with-config-path/basic.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | target: "node",
4 | stats: "verbose",
5 | };
6 |
--------------------------------------------------------------------------------
/test/configtest/with-config-path/error.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "dev", // error
3 | target: "node",
4 | stats: "normal",
5 | };
6 |
--------------------------------------------------------------------------------
/test/watch/bail/no-bail-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: false,
3 | entry: "./src/first.js",
4 | mode: "development",
5 | };
6 |
--------------------------------------------------------------------------------
/test/watch/basic/log.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | infrastructureLogging: {
4 | level: "log",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-cjs-using-nodejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "engines": {
4 | "node": ">=18.12.0"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-mjs-using-nodejs/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "engines": {
4 | "node": ">=18.12.0"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-ts-node-loader/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "type": "module",
3 | "engines": {
4 | "node": ">=18.12.0"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/build/config/error-mjs/webpack.config.mjs:
--------------------------------------------------------------------------------
1 | export default {
2 | name: "config-error",
3 | mode: "unknown", // error
4 | target: "node",
5 | };
6 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-error/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "invalid",
3 | target: "node",
4 | stats: "verbose",
5 | };
6 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | target: "node",
4 | stats: "verbose",
5 | };
6 |
--------------------------------------------------------------------------------
/.nycrc:
--------------------------------------------------------------------------------
1 | {
2 | "include": ["packages/**"],
3 | "reporter": ["html", "json", "cobertura"],
4 | "source-map": true,
5 | "exclude-after-remap": false
6 | }
7 |
--------------------------------------------------------------------------------
/scripts/global-setup.js:
--------------------------------------------------------------------------------
1 | const { version } = require("webpack");
2 |
3 | module.exports = () => console.log(`\n Running tests for webpack @${version} \n`);
4 |
--------------------------------------------------------------------------------
/test/build/config/error-commonjs/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: "config-error",
3 | mode: "unknown", // error
4 | target: "node",
5 | };
6 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-custom-extension/webpack.config.json:
--------------------------------------------------------------------------------
1 | {
2 | "mode": "development",
3 | "target": "node",
4 | "stats": "verbose"
5 | }
6 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/loader/default/test/fixtures/simple-file.js.tpl:
--------------------------------------------------------------------------------
1 | import foo from "./foo"; // eslint-disable-line
2 |
3 | console.log(foo);
4 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/test/fixtures/simple-file.js.tpl:
--------------------------------------------------------------------------------
1 | import foo from "./foo"; // eslint-disable-line
2 |
3 | console.log(foo);
4 |
--------------------------------------------------------------------------------
/test/build/bail/bail-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: false,
3 | entry: "./src/first.js",
4 | mode: "development",
5 | bail: true,
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/bail/watch-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: false,
3 | entry: "./src/first.js",
4 | mode: "development",
5 | watch: true,
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/output/webpack.defaults.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: {
3 | b: "./b.js",
4 | c: "./c.js",
5 | },
6 | mode: "development",
7 | };
8 |
--------------------------------------------------------------------------------
/test/serve/invalid-schema/webpack-dev-server.config.mock.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | devServer: {
4 | bonjour: "",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/watch/bail/bail-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: false,
3 | entry: "./src/first.js",
4 | mode: "development",
5 | bail: true,
6 | };
7 |
--------------------------------------------------------------------------------
/test/watch/bail/watch-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | devtool: false,
3 | entry: "./src/first.js",
4 | mode: "development",
5 | watch: true,
6 | };
7 |
--------------------------------------------------------------------------------
/test/api/resolve-config/webpack.config1.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | output: {
3 | libraryTarget: "amd",
4 | },
5 | entry: "./a.js",
6 | name: "amd",
7 | };
8 |
--------------------------------------------------------------------------------
/test/build/config/defaults/mjs-config/webpack.config.mjs:
--------------------------------------------------------------------------------
1 | export default {
2 | mode: "development",
3 | output: {
4 | filename: "test-output.js",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/utils/exec-in-directory.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const [, , dir, bin] = process.argv;
4 | process.argv.splice(1, 2);
5 | process.chdir(dir);
6 |
7 | require(bin);
8 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/loader/default/package.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "description": "webpack loader",
4 | "name": "<%= name %>"
5 | }
6 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/package.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "description": "webpack plugin",
4 | "name": "<%= name %>"
5 | }
6 |
--------------------------------------------------------------------------------
/test/build/config/defaults/basic-config/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | output: {
4 | filename: "test-output.js",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/config/defaults/cjs-config/webpack.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | output: {
4 | filename: "test-output.js",
5 | },
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/merge/config/2.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: "./second-entry.js",
3 | target: "node",
4 | output: {
5 | filename: "second-output.js",
6 | },
7 | };
8 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/index.d.ts.tpl:
--------------------------------------------------------------------------------
1 | declare module '*.svelte' {
2 | export { SvelteComponentDev as default } from 'svelte/internal';
3 | }
4 |
--------------------------------------------------------------------------------
/test/build/build-warnings/src/index.js:
--------------------------------------------------------------------------------
1 | let obj;
2 |
3 | try {
4 | obj = require('unknown');
5 | } catch (e) {
6 | // Ignore
7 | }
8 |
9 | export default obj
10 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-ts-node-loader/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "module": "esnext",
4 | "allowSyntheticDefaultImports": true
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/build/config/type/function-with-env/a.js:
--------------------------------------------------------------------------------
1 | console.log("chuntaro");
2 | // eslint-disable-next-line no-undef
3 | if (envMessage) {
4 | console.log("env message present");
5 | }
6 |
--------------------------------------------------------------------------------
/lint-staged.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | "*": ["prettier --cache --write --ignore-unknown", "cspell --cache --no-must-find-files"],
3 | "*.{js,ts}": ["eslint --cache --fix"],
4 | };
5 |
--------------------------------------------------------------------------------
/test/build/config/error-mjs/syntax-error.mjs:
--------------------------------------------------------------------------------
1 | export default {
2 | name: 'config-error',
3 | mode: 'development',
4 | target: 'node'; //SyntaxError: Unexpected token ';'
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/core-flags/my-warning-loader.js:
--------------------------------------------------------------------------------
1 | module.exports = function loader(source) {
2 | const { emitWarning } = this;
3 | emitWarning("Generated Warning");
4 | return source;
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/bail/bail-and-watch-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: "./src/first.js",
3 | devtool: false,
4 | mode: "development",
5 | bail: true,
6 | watch: true,
7 | };
8 |
--------------------------------------------------------------------------------
/test/build/config/error-commonjs/syntax-error.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: 'config-error',
3 | mode: 'development',
4 | target: 'node'; //SyntaxError: Unexpected token ';'
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/name/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | plugins: [new WebpackCLITestPlugin()],
5 | };
6 |
--------------------------------------------------------------------------------
/test/watch/bail/bail-and-watch-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | entry: "./src/first.js",
3 | devtool: false,
4 | mode: "development",
5 | bail: true,
6 | watch: true,
7 | };
8 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/vue/src/assets/webpack.png.tpl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/webpack/webpack-cli/main/packages/create-webpack-app/templates/init/vue/src/assets/webpack.png.tpl
--------------------------------------------------------------------------------
/test/build/config/function/single-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => ({
2 | output: {
3 | filename: "./dist-single.js",
4 | },
5 | name: "single",
6 | mode: "development",
7 | });
8 |
--------------------------------------------------------------------------------
/test/build/node-env/auto-mode.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | plugins: [new WebpackCLITestPlugin()],
5 | };
6 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/assets/webpack.png.tpl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/webpack/webpack-cli/main/packages/create-webpack-app/templates/init/react/src/assets/webpack.png.tpl
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/assets/webpack.png.tpl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/webpack/webpack-cli/main/packages/create-webpack-app/templates/init/svelte/src/assets/webpack.png.tpl
--------------------------------------------------------------------------------
/test/api/resolve-config/webpack.config2.cjs:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | output: {
3 | libraryTarget: "commonjs",
4 | },
5 | entry: "./a.js",
6 | mode: "production",
7 | target: "node",
8 | };
9 |
--------------------------------------------------------------------------------
/test/build/config-node-env/auto-mode.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | plugins: [new WebpackCLITestPlugin()],
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/config/object-freeze-partial/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | cache: Object.freeze({ type: "filesystem" }),
3 | stats: Object.freeze({}),
4 | plugins: Object.freeze([]),
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/error/error-in-plugin/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | plugins: [
3 | {
4 | apply() {
5 | throw new Error("test");
6 | },
7 | },
8 | ],
9 | };
10 |
--------------------------------------------------------------------------------
/test/create-webpack-app/loader/warning-test/my-loader.js:
--------------------------------------------------------------------------------
1 | module.exports = function loader(source) {
2 | const { emitWarning } = this;
3 | emitWarning("This is a warning");
4 | return source;
5 | };
6 |
--------------------------------------------------------------------------------
/test/watch/stdin/multi-serve.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | entry: "./src/second.js",
4 | },
5 | {
6 | watchOptions: {
7 | stdin: true,
8 | },
9 | },
10 | ];
11 |
--------------------------------------------------------------------------------
/test/build/config-name/single-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | output: {
3 | filename: "./dist-single.js",
4 | },
5 | name: "first",
6 | entry: "./src/first.js",
7 | mode: "development",
8 | };
9 |
--------------------------------------------------------------------------------
/test/build/target/node/__snapshots__/node-test.test.js.snap.webpack5:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2 |
3 | exports[`Node target should emit the correct code: stderr 1`] = `""`;
4 |
--------------------------------------------------------------------------------
/test/configtest/with-config-path/syntax-error.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: 'config-error',
3 | mode: 'development',
4 | // SyntaxError: Unexpected token ';'
5 | target: 'node';
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/config-name/single-other-config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | output: {
3 | filename: "./dist-single.js",
4 | },
5 | name: "four",
6 | entry: "./src/first.js",
7 | mode: "development",
8 | };
9 |
--------------------------------------------------------------------------------
/test/build/mode/mode-with-config/webpack.config3.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | plugins: [new WebpackCLITestPlugin()],
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/colors/stats-colors.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | stats: {
3 | colors: {
4 | green: "\u001B[31m", // overwriting with red for test
5 | },
6 | },
7 | mode: "development",
8 | };
9 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/default/babel.config.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "presets": [
3 | [
4 | "@babel/preset-env",
5 | {
6 | "modules": false
7 | }
8 | ]
9 | ]
10 | }
11 |
--------------------------------------------------------------------------------
/test/watch/stdin/multi-watch.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | entry: "./src/second.js",
4 | },
5 | {
6 | watch: true,
7 | watchOptions: {
8 | stdin: true,
9 | },
10 | },
11 | ];
12 |
--------------------------------------------------------------------------------
/scripts/setup-test.js:
--------------------------------------------------------------------------------
1 | /* global jest, expect */
2 |
3 | jest.setTimeout(180000);
4 |
5 | if (!expect.getState().testPath.includes("colors.test.js")) {
6 | process.env.FORCE_COLOR = 0;
7 | process.env.NO_COLOR = true;
8 | }
9 |
--------------------------------------------------------------------------------
/test/build/node-env/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: process.env.NODE_ENV,
5 | plugins: [new WebpackCLITestPlugin()],
6 | };
7 |
--------------------------------------------------------------------------------
/commitlint.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | extends: ["@commitlint/config-conventional"],
3 | rules: {
4 | "header-max-length": [0],
5 | "body-max-line-length": [0],
6 | "footer-max-line-length": [0],
7 | },
8 | };
9 |
--------------------------------------------------------------------------------
/test/build/start-finish-force-log/webpack.config.array.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | name: "Gojou",
4 | mode: "development",
5 | },
6 | {
7 | name: "Satoru",
8 | mode: "development",
9 | },
10 | ];
11 |
--------------------------------------------------------------------------------
/test/api/resolve-config/env.webpack.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = function configuration(env) {
2 | const configName = env.name;
3 | return {
4 | name: configName,
5 | mode: env.test ? "staging" : "production",
6 | };
7 | };
8 |
--------------------------------------------------------------------------------
/test/build/config-node-env/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: process.env.NODE_ENV,
5 | plugins: [new WebpackCLITestPlugin()],
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/mode/mode-with-config/webpack.config2.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | plugins: [new WebpackCLITestPlugin()],
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/entry/flag-entry/entry.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | entry: "./src/index.cjs",
5 | plugins: [new WebpackCLITestPlugin(["entry"])],
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/mode/mode-single-arg/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | entry: "./src/index.js",
5 | plugins: [new WebpackCLITestPlugin()],
6 | };
7 |
--------------------------------------------------------------------------------
/test/serve/basic/log.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | infrastructureLogging: {
4 | level: "log",
5 | },
6 | devServer: {
7 | client: {
8 | logging: "info",
9 | },
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/App.jsx.tpl:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import AppRouter from "./router";
3 |
4 | const App = () => {
5 | return (
6 |
7 | );
8 | }
9 |
10 | export default App;
11 |
--------------------------------------------------------------------------------
/packages/webpack-cli/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./lib",
5 | "rootDir": "./src",
6 | "typeRoots": ["./src/types.ts"]
7 | },
8 | "include": ["./src"]
9 | }
10 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-using-nodejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "allowImportingTsExtensions": true,
5 | "rewriteRelativeImportExtensions": true,
6 | "module": "esnext"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/build/config/basic/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: "./a.js",
5 | output: {
6 | path: resolve(__dirname, "binary"),
7 | filename: "a.bundle.js",
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/node/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: "./a.js",
5 | output: {
6 | path: resolve(__dirname, "binary"),
7 | filename: "[name].bundle.js",
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/stats/flags/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | entry: "./index.js",
6 | plugins: [new WebpackCLITestPlugin()],
7 | };
8 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-cjs-using-nodejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "allowImportingTsExtensions": true,
5 | "rewriteRelativeImportExtensions": true,
6 | "module": "esnext"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-mjs-using-nodejs/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "allowImportingTsExtensions": true,
5 | "rewriteRelativeImportExtensions": true,
6 | "module": "esnext"
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/test/build/extends/recursive-extends/other.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => ({
4 | extends: "./webpack.config.js",
5 | plugins: [new WebpackCLITestPlugin()],
6 | });
7 |
--------------------------------------------------------------------------------
/test/build/extends/simple-case/override.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("override.config.js");
3 |
4 | return {
5 | name: "override_config",
6 | mode: "development",
7 | entry: "./src/index.js",
8 | };
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/target/flag-test/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | entry: "./index.js",
5 | mode: "development",
6 | plugins: [new WebpackCLITestPlugin()],
7 | };
8 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/App.tsx.tpl:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import AppRouter from "./router";
3 |
4 | const App: React.FC = () => {
5 | return (
6 |
7 | );
8 | }
9 |
10 | export default App;
11 |
--------------------------------------------------------------------------------
/test/build/config-lookup/relative/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: "./a.js",
5 | output: {
6 | path: resolve(__dirname, "binary"),
7 | filename: "a.bundle.js",
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/extends/recursive-extends/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => ({
4 | extends: "./webpack.config.js",
5 | plugins: [new WebpackCLITestPlugin()],
6 | });
7 |
--------------------------------------------------------------------------------
/test/build/extends/simple-case/base.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("base.webpack.config.js");
3 |
4 | return {
5 | name: "base_config",
6 | mode: "development",
7 | entry: "./src/index.js",
8 | };
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/config/type/function/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = () => ({
4 | entry: "./a",
5 | output: {
6 | path: path.resolve(__dirname, "./binary"),
7 | filename: "functor.js",
8 | },
9 | });
10 |
--------------------------------------------------------------------------------
/test/build/extends/extends-cli-option/base.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("base.webpack.config.js");
3 |
4 | return {
5 | name: "base_config",
6 | mode: "development",
7 | entry: "./src/index.js",
8 | };
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-extends/base1.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("base1.webpack.config.js");
3 |
4 | return {
5 | name: "base_config1",
6 | mode: "development",
7 | entry: "./src/index.js",
8 | };
9 | };
10 |
--------------------------------------------------------------------------------
/test/serve/basic/helper/base-dev-server.config.js:
--------------------------------------------------------------------------------
1 | const devServerConfig = {
2 | devMiddleware: {
3 | publicPath: "/dev-server-my-public-path/",
4 | },
5 | client: {
6 | logging: "info",
7 | },
8 | };
9 |
10 | module.exports = devServerConfig;
11 |
--------------------------------------------------------------------------------
/test/serve/basic/stats.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | mode: "development",
3 | devtool: false,
4 | devServer: {
5 | devMiddleware: {
6 | stats: "minimal",
7 | },
8 | client: {
9 | logging: "info",
10 | },
11 | },
12 | };
13 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/default/postcss.config.js.tpl:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | // Add you postcss configuration here
3 | // Learn more about it at https://github.com/webpack-contrib/postcss-loader#config-files
4 | plugins: [["autoprefixer"]],
5 | };
6 |
--------------------------------------------------------------------------------
/test/build/config/defaults/with-mode/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: "./index.js",
5 | output: {
6 | path: resolve(__dirname, "./binary"),
7 | filename: "dev.bundle.js",
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/error/invalid-schema/webpack.plugin-mock.config.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 |
3 | module.exports = {
4 | mode: "development",
5 | plugins: [
6 | new webpack.BannerPlugin({
7 | unknown: "unknown",
8 | }),
9 | ],
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/extends/multi-level-extends/base2.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("base2.webpack.config.js");
3 |
4 | return {
5 | name: "base_config2",
6 | mode: "development",
7 | entry: "./src/index2.js",
8 | };
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/output/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: "./a.js",
5 | mode: "development",
6 | output: {
7 | path: resolve(__dirname, "bin"),
8 | filename: "a.bundle.js",
9 | },
10 | };
11 |
--------------------------------------------------------------------------------
/packages/webpack-cli/src/index.ts:
--------------------------------------------------------------------------------
1 | import WebpackCLI from "./webpack-cli.js";
2 |
3 | export type * from "./types.js";
4 | export { default } from "./webpack-cli.js";
5 |
6 | // TODO remove me in the next major release and use `default` export
7 | module.exports = WebpackCLI;
8 |
--------------------------------------------------------------------------------
/test/build/config-lookup/custom-name/config.webpack.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: resolve("./a.js"),
5 | output: {
6 | path: resolve(__dirname, "binary"),
7 | filename: "a.bundle.js",
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/config/error-array/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | name: 'kiryu',
4 | target: 'node', // no error
5 | },
6 | {
7 | name: 'config-error',
8 | target: 'node'; // error eslint-ignore
9 | }
10 | ]
11 |
--------------------------------------------------------------------------------
/test/build/config/type/function-async/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = async () => ({
4 | entry: "./a",
5 | output: {
6 | path: path.resolve(__dirname, "./binary"),
7 | filename: "functor.js",
8 | },
9 | });
10 |
--------------------------------------------------------------------------------
/test/build/progress/webpack.progress.config.js:
--------------------------------------------------------------------------------
1 | const { ProgressPlugin } = require("webpack");
2 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
3 |
4 | module.exports = {
5 | plugins: [new ProgressPlugin({}), new WebpackCLITestPlugin()],
6 | };
7 |
--------------------------------------------------------------------------------
/test/build/stats/config/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | entry: "./index.js",
6 | stats: "normal",
7 | plugins: [new WebpackCLITestPlugin()],
8 | };
9 |
--------------------------------------------------------------------------------
/test/build/config/multiple/webpack2.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | output: {
3 | filename: "./dist-commonjs.js",
4 | libraryTarget: "commonjs",
5 | },
6 | name: "commonjs",
7 | entry: "./init.js",
8 | mode: "development",
9 | target: "node",
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/entry/config-entry/1.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: {
5 | index: "../a.js",
6 | },
7 | output: {
8 | path: resolve(process.cwd(), "binary"),
9 | filename: "[name].bundle.js",
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/test/build/stats/config-no/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | entry: "./main.js",
6 | stats: "detailed",
7 | plugins: [new WebpackCLITestPlugin()],
8 | };
9 |
--------------------------------------------------------------------------------
/test/build/target/flag-test/target.web.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | entry: "./index.js",
5 | mode: "development",
6 | target: "web",
7 | plugins: [new WebpackCLITestPlugin()],
8 | };
9 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/index.d.ts.tpl:
--------------------------------------------------------------------------------
1 | declare module "*.png";
2 | declare module "*.jpg";
3 | declare module "*.gif";
4 | declare module "*.svg";
5 | declare module "*.ttf";
6 | declare module "*.woff";
7 | declare module "*.woff2";
8 | declare module "*.eot";
9 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs/other.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("other.config.js");
3 |
4 | return {
5 | name: "other_config",
6 | mode: "development",
7 | experiments: {
8 | topLevelAwait: true,
9 | },
10 | };
11 | };
12 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs1/other.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("other.config.js");
3 |
4 | return {
5 | name: "other_config",
6 | mode: "development",
7 | experiments: {
8 | topLevelAwait: true,
9 | },
10 | };
11 | };
12 |
--------------------------------------------------------------------------------
/packages/info/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./lib",
5 | "rootDir": "./src"
6 | },
7 | "include": ["./src"],
8 | "references": [
9 | {
10 | "path": "../webpack-cli"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/packages/serve/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./lib",
5 | "rootDir": "./src"
6 | },
7 | "include": ["./src"],
8 | "references": [
9 | {
10 | "path": "../webpack-cli"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/test/build/config/multiple/webpack1.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | output: {
3 | filename: "./dist-amd.js",
4 | libraryTarget: "amd",
5 | },
6 | name: "amd",
7 | entry: "./init.js",
8 | mode: "development",
9 | devtool: "eval-cheap-module-source-map",
10 | };
11 |
--------------------------------------------------------------------------------
/packages/configtest/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "./lib",
5 | "rootDir": "./src"
6 | },
7 | "include": ["./src"],
8 | "references": [
9 | {
10 | "path": "../webpack-cli"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/test/build/config-format/coffee/webpack.config.coffee:
--------------------------------------------------------------------------------
1 | path = require 'path'
2 |
3 | config =
4 | mode: 'development'
5 | entry: './main.js'
6 | output:
7 | path: path.resolve(__dirname, 'dist')
8 | filename: 'foo.bundle.js'
9 |
10 | module.exports = config;
11 |
--------------------------------------------------------------------------------
/test/build/config-format/failure/webpack.config.iced:
--------------------------------------------------------------------------------
1 | path = require 'path'
2 |
3 | config =
4 | mode: 'development'
5 | entry: './main.js'
6 | output:
7 | path: path.resolve(__dirname, 'dist')
8 | filename: 'foo.bundle.js'
9 |
10 | module.exports = config;
11 |
--------------------------------------------------------------------------------
/test/build/config/defaults/dot-webpack-directory/.webpack/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: "./index.js",
5 | output: {
6 | path: resolve(__dirname, "../binary"),
7 | filename: "dev.bundle.js",
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/extends/extends-cli-option/deep.base.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("deep.base.webpack.config.js");
3 |
4 | return {
5 | name: "base_config",
6 | mode: "development",
7 | entry: "./src/index.js",
8 | bail: true,
9 | };
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/target/flag-test/multiple-target.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | entry: "./index.js",
5 | mode: "development",
6 | target: ["web", "es5"],
7 | plugins: [new WebpackCLITestPlugin()],
8 | };
9 |
--------------------------------------------------------------------------------
/test/build/config-format/babel-commonjs/webpack.config.babel.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = {
4 | mode: "development",
5 | entry: "./main.js",
6 | output: {
7 | path: path.resolve(__dirname, "dist"),
8 | filename: "foo.bundle.js",
9 | },
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/config/top-multi-compilers-options/index.js:
--------------------------------------------------------------------------------
1 | console.log(`test ${Math.random()}`);
2 | console.log(`test ${Math.random()}`);
3 | console.log(`test ${Math.random()}`);
4 | console.log(`test ${Math.random()}`);
5 | console.log(`test ${Math.random()}`);
6 | console.log(`test ${Math.random()}`);
7 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-extends/base2.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("base2.webpack.config.js");
3 |
4 | return {
5 | name: "base_config2",
6 | entry: "./src/index2.js",
7 | externals: {
8 | jquery: "jQuery",
9 | },
10 | };
11 | };
12 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-multi-compiler-mode/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | mode: "development",
4 | target: "node",
5 | stats: "verbose",
6 | },
7 | {
8 | mode: "development",
9 | target: "node",
10 | stats: "verbose",
11 | },
12 | ];
13 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/default/tsconfig.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "allowSyntheticDefaultImports": true,
4 | "noImplicitAny": true,
5 | "module": "es6",
6 | "target": "es5",
7 | "allowJs": true
8 | },
9 | "files": ["src/index.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/vue/src/components/Layout.vue.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
15 |
--------------------------------------------------------------------------------
/test/build/config/defaults/dot-webpack-directory-webpackfile/.webpack/webpackfile.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: "./index.js",
5 | output: {
6 | path: resolve(__dirname, "../binary"),
7 | filename: "dev.folder.js",
8 | },
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/config/multiple-with-one-compilation/webpack.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = [
4 | {
5 | entry: "./a.js",
6 | output: {
7 | path: resolve(__dirname, "binary"),
8 | filename: "a.bundle.js",
9 | },
10 | },
11 | ];
12 |
--------------------------------------------------------------------------------
/test/build/config/type/function-with-argv/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = (env, argv) => {
2 | console.log({ argv });
3 | const { mode } = argv;
4 | return {
5 | entry: "./a.js",
6 | output: {
7 | filename: mode === "production" ? "prod.js" : "dev.js",
8 | },
9 | };
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/extends/extends-cli-option/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => {
4 | console.log("derived.webpack.config.js");
5 |
6 | return {
7 | plugins: [new WebpackCLITestPlugin()],
8 | };
9 | };
10 |
--------------------------------------------------------------------------------
/test/build/analyze/analyze.config.js:
--------------------------------------------------------------------------------
1 | const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
2 |
3 | module.exports = {
4 | mode: "development",
5 | plugins: [
6 | new BundleAnalyzerPlugin({
7 | analyzerMode: "static",
8 | openAnalyzer: false,
9 | }),
10 | ],
11 | };
12 |
--------------------------------------------------------------------------------
/test/watch/analyze/analyze.config.js:
--------------------------------------------------------------------------------
1 | const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer");
2 |
3 | module.exports = {
4 | mode: "development",
5 | plugins: [
6 | new BundleAnalyzerPlugin({
7 | analyzerMode: "static",
8 | openAnalyzer: false,
9 | }),
10 | ],
11 | };
12 |
--------------------------------------------------------------------------------
/test/build/merge/config/1.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | entry: "./first-entry.js",
5 | mode: "development",
6 | output: {
7 | filename: "first-output.js",
8 | },
9 | plugins: [new WebpackCLITestPlugin()],
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/mode/mode-with-config/src/index.js:
--------------------------------------------------------------------------------
1 | console.log("Ichigo");
2 |
3 | if (process.env.NODE_ENV === "production") {
4 | console.log("production mode");
5 | } else if (process.env.NODE_ENV === "development") {
6 | console.log("development mode");
7 | } else {
8 | console.log("none mode");
9 | }
10 |
--------------------------------------------------------------------------------
/test/create-webpack-app/loader/error-test/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "buildOnSave": false,
4 | "compilerOptions": {
5 | "target": "es6",
6 | "moduleResolution": "node",
7 | "noEmitOnError": false,
8 | "outDir": "./dist"
9 | },
10 | "exclude": ["node_modules"]
11 | }
12 |
--------------------------------------------------------------------------------
/test/build/config-format/commonjs/webpack.config.cjs:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | const config = {
4 | mode: "development",
5 | entry: "./main.js",
6 | output: {
7 | path: path.resolve(__dirname, "dist"),
8 | filename: "foo.bundle.js",
9 | },
10 | };
11 |
12 | module.exports = config;
13 |
--------------------------------------------------------------------------------
/test/build/config-format/disable-interpret/webpack.config.ts:
--------------------------------------------------------------------------------
1 | import * as path from "node:path";
2 |
3 | const config = {
4 | mode: "development",
5 | entry: "./main.ts",
6 | output: {
7 | path: path.resolve(__dirname, "dist"),
8 | filename: "foo.bundle.js",
9 | },
10 | };
11 |
12 | export = config;
13 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/vue/README.md.tpl:
--------------------------------------------------------------------------------
1 | # 🚀 Welcome to your new awesome project!
2 |
3 | This project has been created using **create-webpack-app**, you can now run
4 |
5 | ```bash
6 | npm run build
7 | ```
8 |
9 | or
10 |
11 | ```bash
12 | yarn build
13 | ```
14 |
15 | to bundle your application
16 |
--------------------------------------------------------------------------------
/test/build/core-flags/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | entry: "./src/main.js",
5 | mode: "development",
6 | name: "compiler",
7 | plugins: [new WebpackCLITestPlugin(["module", "entry", "resolve", "resolveLoader", "cache"])],
8 | };
9 |
--------------------------------------------------------------------------------
/test/build/output/webpack.multiple.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: {
5 | b: "./b.js",
6 | c: "./c.js",
7 | },
8 | output: {
9 | path: resolve(__dirname, "bin"),
10 | filename: "[name].bundle.js",
11 | },
12 | mode: "development",
13 | };
14 |
--------------------------------------------------------------------------------
/test/build/output/webpack.single.config.js:
--------------------------------------------------------------------------------
1 | const { resolve } = require("node:path");
2 |
3 | module.exports = {
4 | entry: {
5 | b: "./b.js",
6 | c: "./c.js",
7 | },
8 | output: {
9 | path: resolve(__dirname, "bin"),
10 | filename: "[name].bundle.js",
11 | },
12 | mode: "development",
13 | };
14 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | root = true
2 |
3 | [*]
4 | charset = utf-8
5 | indent_style = space
6 | indent_size = 2
7 | end_of_line = lf
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 |
11 | [*.md]
12 | trim_trailing_whitespace = false
13 |
14 | [test/cases/parsing/bom/bomfile.{css,js}]
15 | charset = utf-8-bom
16 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/default/README.md.tpl:
--------------------------------------------------------------------------------
1 | # 🚀 Welcome to your new awesome project!
2 |
3 | This project has been created using **create-webpack-app**, you can now run
4 |
5 | ```bash
6 | npm run build
7 | ```
8 |
9 | or
10 |
11 | ```bash
12 | yarn build
13 | ```
14 |
15 | to bundle your application
16 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/README.md.tpl:
--------------------------------------------------------------------------------
1 | # 🚀 Welcome to your new awesome project!
2 |
3 | This project has been created using **create-webpack-app**, you can now run
4 |
5 | ```bash
6 | npm run build
7 | ```
8 |
9 | or
10 |
11 | ```bash
12 | yarn build
13 | ```
14 |
15 | to bundle your application
16 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/README.md.tpl:
--------------------------------------------------------------------------------
1 | # 🚀 Welcome to your new awesome project!
2 |
3 | This project has been created using **create-webpack-app**, you can now run
4 |
5 | ```bash
6 | npm run build
7 | ```
8 |
9 | or
10 |
11 | ```bash
12 | yarn build
13 | ```
14 |
15 | to bundle your application
16 |
--------------------------------------------------------------------------------
/test/build/config-lookup/custom-name/config.webpack.mjs:
--------------------------------------------------------------------------------
1 | import path from "node:path";
2 | import { fileURLToPath } from "node:url";
3 |
4 | export default {
5 | entry: "./a.js",
6 | output: {
7 | path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "dist"),
8 | filename: "a.bundle.js",
9 | },
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/env/object/webpack.config.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 |
3 | module.exports = {
4 | mode: "development",
5 | devtool: "eval-cheap-module-source-map",
6 | target: "node",
7 | plugins: [
8 | new webpack.DefinePlugin({
9 | PRODUCTION: JSON.stringify(false),
10 | }),
11 | ],
12 | };
13 |
--------------------------------------------------------------------------------
/test/build/config-format/commonjs-default/webpack.config.cjs:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | const config = {
4 | mode: "development",
5 | entry: "./main.js",
6 | output: {
7 | path: path.resolve(__dirname, "dist"),
8 | filename: "foo.bundle.js",
9 | },
10 | };
11 |
12 | module.exports.default = config;
13 |
--------------------------------------------------------------------------------
/test/build/colors/multiple-configs.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | name: "first-config",
4 | entry: "./src/first.js",
5 | stats: "normal",
6 | mode: "development",
7 | },
8 | {
9 | name: "second-config",
10 | entry: "./src/second.js",
11 | stats: "normal",
12 | mode: "development",
13 | },
14 | ];
15 |
--------------------------------------------------------------------------------
/test/build/extends/simple-case/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => {
4 | console.log("derived.webpack.config.js");
5 |
6 | return {
7 | extends: "./base.webpack.config.js",
8 | plugins: [new WebpackCLITestPlugin()],
9 | };
10 | };
11 |
--------------------------------------------------------------------------------
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "webpack-cli",
3 | "dockerFile": "Dockerfile",
4 | "runArgs": ["-u", "node"],
5 | "settings": {
6 | "terminal.integrated.shell.linux": "/bin/bash"
7 | },
8 | "postCreateCommand": "npm install && npm run build",
9 | "extensions": ["dbaeumer.vscode-eslint", "esbenp.prettier-vscode"]
10 | }
11 |
--------------------------------------------------------------------------------
/test/build/config-format/esm-require/webpack.config.js:
--------------------------------------------------------------------------------
1 | import { fileURLToPath } from "url";
2 | import path from "path";
3 |
4 | export default {
5 | mode: "development",
6 | entry: "./main.js",
7 | output: {
8 | path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "dist"),
9 | filename: "foo.bundle.js",
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/test/build/config-format/esm/webpack.config.mjs:
--------------------------------------------------------------------------------
1 | import path from "node:path";
2 | import { fileURLToPath } from "node:url";
3 |
4 | export default {
5 | mode: "development",
6 | entry: "./main.js",
7 | output: {
8 | path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "dist"),
9 | filename: "foo.bundle.js",
10 | },
11 | };
12 |
--------------------------------------------------------------------------------
/test/build/extends/multi-level-extends/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => {
4 | console.log("derived.webpack.config.js");
5 |
6 | return {
7 | extends: ["./base1.webpack.config.js"],
8 | plugins: [new WebpackCLITestPlugin()],
9 | };
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs1/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("derived.webpack.config.js");
3 |
4 | return [
5 | {
6 | name: "derived_config1",
7 | entry: "./src/index1.js",
8 | },
9 | {
10 | name: "derived_config2",
11 | entry: "./src/index2.js",
12 | },
13 | ];
14 | };
15 |
--------------------------------------------------------------------------------
/test/build/mode/mode-with-config/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
3 |
4 | module.exports = {
5 | output: {
6 | path: path.join(__dirname, "dist"),
7 | filename: "[name].js",
8 | },
9 | plugins: [new WebpackCLITestPlugin()],
10 | };
11 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/loader/default/examples/simple/src/index.js.tpl:
--------------------------------------------------------------------------------
1 | import esmModule from './static-esm-module';
2 |
3 | const getLazyModule = () => System.import('./lazy-module');
4 |
5 | setTimeout(() => {
6 | getLazyModule.then((modDefault) => {
7 | console.log(modDefault);
8 | });
9 | }, 300);
10 |
11 | console.log(esmModule);
12 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/examples/simple/src/index.js.tpl:
--------------------------------------------------------------------------------
1 | import esmModule from './static-esm-module';
2 |
3 | const getLazyModule = () => System.import('./lazy-module');
4 |
5 | setTimeout(() => {
6 | getLazyModule.then((modDefault) => {
7 | console.log(modDefault);
8 | });
9 | }, 300);
10 |
11 | console.log(esmModule);
12 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.json",
3 | "exclude": ["src/utils/__tests__"],
4 | "compilerOptions": {
5 | "outDir": "lib",
6 | "rootDir": "src",
7 | "module": "esnext"
8 | },
9 | "include": ["src"],
10 | "references": [
11 | {
12 | "path": "../webpack-cli"
13 | }
14 | ]
15 | }
16 |
--------------------------------------------------------------------------------
/test/build/entry/config-entry/entry-with-index/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = {
4 | mode: "development",
5 | entry: {
6 | app: "./src/app.js",
7 | print: "./src/print.js",
8 | },
9 | output: {
10 | filename: "[name].bundle.js",
11 | path: path.resolve(__dirname, "dist"),
12 | },
13 | };
14 |
--------------------------------------------------------------------------------
/test/serve/basic/serve.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | devtool: false,
6 | plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")],
7 | devServer: {
8 | client: {
9 | logging: "info",
10 | },
11 | },
12 | };
13 |
--------------------------------------------------------------------------------
/test/serve/basic/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | devtool: false,
6 | plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")],
7 | devServer: {
8 | client: {
9 | logging: "info",
10 | },
11 | },
12 | };
13 |
--------------------------------------------------------------------------------
/lerna.json:
--------------------------------------------------------------------------------
1 | {
2 | "packages": ["packages/*"],
3 | "version": "independent",
4 | "npmClient": "npm",
5 | "command": {
6 | "version": {
7 | "message": "chore(release): publish new version",
8 | "conventionalCommits": true,
9 | "allowBranch": ["main", "next"]
10 | }
11 | },
12 | "$schema": "node_modules/lerna/schemas/lerna-schema.json"
13 | }
14 |
--------------------------------------------------------------------------------
/test/build/extends/multi-level-extends/base1.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("base1.webpack.config.js");
3 |
4 | return {
5 | name: "base_config1",
6 | extends: ["./base2.webpack.config.js"],
7 | mode: "production",
8 | entry: "./src/index1.js",
9 | output: {
10 | filename: "bundle1.js",
11 | },
12 | };
13 | };
14 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-extends/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => {
4 | console.log("derived.webpack.config.js");
5 |
6 | return {
7 | extends: ["./base1.webpack.config.js", "./base2.webpack.config.js"],
8 | plugins: [new WebpackCLITestPlugin()],
9 | };
10 | };
11 |
--------------------------------------------------------------------------------
/test/build/config/type/promise-function/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = new Promise((resolve) => {
4 | setTimeout(() => {
5 | resolve(() => ({
6 | entry: "./a",
7 | output: {
8 | path: path.resolve(__dirname, "./binary"),
9 | filename: "promise.js",
10 | },
11 | }));
12 | }, 0);
13 | });
14 |
--------------------------------------------------------------------------------
/test/build/core-flags/webpack.cache.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | entry: "./src/main.js",
5 | mode: "development",
6 | cache: {
7 | type: "filesystem",
8 | name: "config-cache",
9 | },
10 | name: "compiler-cache",
11 | plugins: [new WebpackCLITestPlugin(["cache"])],
12 | };
13 |
--------------------------------------------------------------------------------
/test/build/entry/scss/scss.test.js:
--------------------------------------------------------------------------------
1 | const { run } = require("../../../utils/test-utils");
2 |
3 | describe("entry point", () => {
4 | it("should support SCSS files", async () => {
5 | const { stdout } = await run(__dirname);
6 |
7 | expect(stdout).toBeTruthy();
8 | expect(stdout).toContain("home.scss");
9 | expect(stdout).toContain("home.js");
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/test/build/config-format/esm-require-await/webpack.config.js:
--------------------------------------------------------------------------------
1 | import { fileURLToPath } from "url";
2 | import path from "path";
3 |
4 | const mode = await "development";
5 |
6 | export default {
7 | mode,
8 | entry: "./main.js",
9 | output: {
10 | path: path.resolve(path.dirname(fileURLToPath(import.meta.url)), "dist"),
11 | filename: "foo.bundle.js",
12 | },
13 | };
14 |
--------------------------------------------------------------------------------
/test/serve/basic/watch.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | devtool: false,
6 | plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")],
7 | watch: true,
8 | devServer: {
9 | client: {
10 | logging: "info",
11 | },
12 | },
13 | };
14 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/vue/index.html.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Vue webpack Project
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/vue/package.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "description": "My webpack project",
4 | "name": "my-webpack-project",
5 | "scripts": {
6 | "build": "webpack --mode=production --node-env=production",
7 | "build:dev": "webpack --mode=development",
8 | "watch": "webpack --watch",
9 | "serve": "webpack serve"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/serve/with-custom-port/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | devtool: false,
6 | stats: "detailed",
7 | devServer: {
8 | port: 1234,
9 | host: "0.0.0.0",
10 | },
11 | plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")],
12 | };
13 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/package.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "description": "My webpack project",
4 | "name": "my-webpack-project",
5 | "scripts": {
6 | "build": "webpack --mode=production --node-env=production",
7 | "build:dev": "webpack --mode=development",
8 | "watch": "webpack --watch",
9 | "serve": "webpack serve"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/index.html.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Svelte Webpack Project
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/package.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 | "description": "My webpack project",
4 | "name": "my-webpack-project",
5 | "scripts": {
6 | "build": "webpack --mode=production --node-env=production",
7 | "build:dev": "webpack --mode=development",
8 | "watch": "webpack --watch",
9 | "serve": "webpack serve"
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/test/build/config/type/promise/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = () =>
4 | new Promise((resolve) => {
5 | setTimeout(() => {
6 | resolve({
7 | entry: "./a",
8 | output: {
9 | path: path.resolve(__dirname, "./binary"),
10 | filename: "promise.js",
11 | },
12 | });
13 | }, 0);
14 | });
15 |
--------------------------------------------------------------------------------
/.codecov.yml:
--------------------------------------------------------------------------------
1 | codecov:
2 | require_ci_to_pass: yes
3 |
4 | coverage:
5 | precision: 2
6 | round: down
7 | range: "50...100"
8 |
9 | parsers:
10 | gcov:
11 | branch_detection:
12 | conditional: yes
13 | loop: yes
14 | method: no
15 | macro: no
16 |
17 | comment:
18 | layout: "reach,diff,flags,files,footer"
19 | behavior: default
20 | require_changes: no
21 |
--------------------------------------------------------------------------------
/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | ## Code of Conduct
2 |
3 | At webpack and webpack/webpack-cli repository we follow the [JSFoundation Code of Conduct][1].
4 | Please adhere to the guidelines there and feel free to report any violation of them to the **@webpack/core-team**,
5 | **@webpack/cli-team**, or .
6 |
7 | [1]: https://github.com/openjs-foundation/code-and-learn/blob/master/CODE_OF_CONDUCT.md
8 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/test/functional.test.js.tpl:
--------------------------------------------------------------------------------
1 | import {
2 | runWebpackExampleInMemory,
3 | } from '../test/test-utils';
4 |
5 | test('should run with no errors or warnings', async () => {
6 | const buildStats = await runWebpackExampleInMemory('simple');
7 | const { errors, warnings } = buildStats;
8 |
9 | expect([...errors, ...warnings].length).toBe(0);
10 | });
11 |
--------------------------------------------------------------------------------
/test/api/resolve-config/webpack.promise.config.cjs:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = () =>
4 | new Promise((resolve) => {
5 | setTimeout(() => {
6 | resolve({
7 | entry: "./a",
8 | output: {
9 | path: path.resolve(__dirname, "./binary"),
10 | filename: "promise.js",
11 | },
12 | });
13 | }, 500);
14 | });
15 |
--------------------------------------------------------------------------------
/test/build/config/type/function-promise/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = () =>
4 | new Promise((resolve) => {
5 | setTimeout(() => {
6 | resolve({
7 | entry: "./a",
8 | output: {
9 | path: path.resolve(__dirname, "./binary"),
10 | filename: "functor.js",
11 | },
12 | });
13 | });
14 | }, 0);
15 |
--------------------------------------------------------------------------------
/test/build/devtool/object/webpack.source.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | output: {
5 | filename: "./dist-amd.js",
6 | libraryTarget: "amd",
7 | },
8 | name: "amd",
9 | entry: "./index.js",
10 | mode: "development",
11 | devtool: "source-map",
12 | plugins: [new WebpackCLITestPlugin()],
13 | };
14 |
--------------------------------------------------------------------------------
/scripts/setup-build.js:
--------------------------------------------------------------------------------
1 | const { readFileSync, writeFileSync } = require("node:fs");
2 | const { resolve } = require("node:path");
3 |
4 | const tsConfigPath = resolve(__dirname, "../tsconfig.json");
5 | const tsConfigRaw = readFileSync(tsConfigPath);
6 | const tsConfig = JSON.parse(tsConfigRaw);
7 |
8 | tsConfig.compilerOptions.sourceMap = true;
9 |
10 | writeFileSync(tsConfigPath, JSON.stringify(tsConfig, null, 2));
11 |
--------------------------------------------------------------------------------
/test/build/config-format/esm/mjs.test.js:
--------------------------------------------------------------------------------
1 | const { run } = require("../../../utils/test-utils");
2 |
3 | describe("webpack cli", () => {
4 | it("should support mjs config format", async () => {
5 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "webpack.config.mjs"]);
6 |
7 | expect(exitCode).toBe(0);
8 | expect(stderr).toBeFalsy();
9 | expect(stdout).toBeTruthy();
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/test/build/devtool/object/webpack.eval.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | output: {
5 | filename: "./dist-amd.js",
6 | libraryTarget: "amd",
7 | },
8 | name: "amd",
9 | entry: "./index.js",
10 | mode: "development",
11 | devtool: "eval-cheap-module-source-map",
12 | plugins: [new WebpackCLITestPlugin()],
13 | };
14 |
--------------------------------------------------------------------------------
/packages/webpack-cli/bin/cli.js:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env node
2 |
3 | "use strict";
4 |
5 | const importLocal = require("import-local");
6 | const runCLI = require("../lib/bootstrap");
7 |
8 | if (
9 | !process.env.WEBPACK_CLI_SKIP_IMPORT_LOCAL && // Prefer the local installation of `webpack-cli`
10 | importLocal(__filename)
11 | ) {
12 | return;
13 | }
14 |
15 | process.title = "webpack";
16 |
17 | runCLI(process.argv);
18 |
--------------------------------------------------------------------------------
/test/build/config-format/commonjs/commonjs.test.js:
--------------------------------------------------------------------------------
1 | const { run } = require("../../../utils/test-utils");
2 |
3 | describe("webpack cli", () => {
4 | it("should support CommonJS file", async () => {
5 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "webpack.config.cjs"]);
6 |
7 | expect(exitCode).toBe(0);
8 | expect(stderr).toBeFalsy();
9 | expect(stdout).toBeTruthy();
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/examples/simple/webpack.config.js.tpl:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 | const <%= pluginIdentifier %> = require('../../src/index.js');
3 |
4 | module.exports = {
5 | entry: './src/index.js',
6 | output: {
7 | path: path.join(__dirname, 'example_dist'),
8 | filename: '[name].chunk.js',
9 | },
10 | plugins: [
11 | new <%= pluginIdentifier %>()
12 | ]
13 | };
14 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-cjs-using-nodejs/webpack.config.ts:
--------------------------------------------------------------------------------
1 | import * as path from "node:path";
2 |
3 | /* eslint-disable no-useless-concat */
4 |
5 | // cspell:ignore elopment
6 | const mode: string = "dev" + "elopment";
7 | const config = {
8 | mode,
9 | entry: "./main.ts",
10 | output: {
11 | path: path.resolve("dist"),
12 | filename: "foo.bundle.js",
13 | },
14 | };
15 |
16 | export default config;
17 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-mjs-using-nodejs/webpack.config.ts:
--------------------------------------------------------------------------------
1 | import * as path from "node:path";
2 |
3 | /* eslint-disable no-useless-concat */
4 |
5 | // cspell:ignore elopment
6 | const mode: string = "dev" + "elopment";
7 | const config = {
8 | mode,
9 | entry: "./main.ts",
10 | output: {
11 | path: path.resolve("dist"),
12 | filename: "foo.bundle.js",
13 | },
14 | };
15 |
16 | export default config;
17 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-ts-node-loader/webpack.config.ts:
--------------------------------------------------------------------------------
1 | import * as path from "node:path";
2 |
3 | /* eslint-disable no-useless-concat */
4 |
5 | // cspell:ignore elopment
6 | const mode: string = "dev" + "elopment";
7 | const config = {
8 | mode,
9 | entry: "./main.ts",
10 | output: {
11 | path: path.resolve("dist"),
12 | filename: "foo.bundle.js",
13 | },
14 | };
15 |
16 | export default config;
17 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-using-nodejs/webpack.config.ts:
--------------------------------------------------------------------------------
1 | import * as path from "node:path";
2 |
3 | /* eslint-disable no-useless-concat */
4 |
5 | // cspell:ignore elopment
6 | const mode: string = "dev" + "elopment";
7 | const config = {
8 | mode,
9 | entry: "./main.ts",
10 | output: {
11 | path: path.resolve("dist"),
12 | filename: "foo.bundle.js",
13 | },
14 | };
15 |
16 | export default config;
17 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs/base.webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => {
4 | console.log("base.webpack.config.js");
5 |
6 | return {
7 | name: "base_config",
8 | mode: "development",
9 | plugins: [new WebpackCLITestPlugin()],
10 |
11 | experiments: {
12 | topLevelAwait: true,
13 | },
14 | };
15 | };
16 |
--------------------------------------------------------------------------------
/test/build/config-format/typescript-ts-node-require/webpack.config.ts:
--------------------------------------------------------------------------------
1 | import * as path from "node:path";
2 |
3 | /* eslint-disable no-useless-concat */
4 |
5 | // cspell:ignore elopment
6 | const mode: string = "dev" + "elopment";
7 | const config = {
8 | mode,
9 | entry: "./main.ts",
10 | output: {
11 | path: path.resolve(__dirname, "dist"),
12 | filename: "foo.bundle.js",
13 | },
14 | };
15 |
16 | export = config;
17 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs1/base.webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => {
4 | console.log("base.webpack.config.js");
5 |
6 | return {
7 | name: "base_config",
8 | mode: "development",
9 | plugins: [new WebpackCLITestPlugin()],
10 |
11 | experiments: {
12 | topLevelAwait: true,
13 | },
14 | };
15 | };
16 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | coverage
2 | .nyc_output
3 | node_modules
4 | dist
5 | packages/*/lib
6 | test/**/dist/
7 | test/**/bin/
8 | test/**/binary/
9 | test/**/index.js
10 | test/build/config/error-commonjs/syntax-error.js
11 | test/build/config/error-array/webpack.config.js
12 | test/build/config/error-mjs/syntax-error.mjs
13 | test/configtest/with-config-path/syntax-error.config.js
14 | test/build/build-errors/stats.json
15 |
16 | /.nx/workspace-data
--------------------------------------------------------------------------------
/test/build/build-variable/build-variable.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { run } = require("../../utils/test-utils");
4 |
5 | describe("bundle variable", () => {
6 | it("compiles without flags and export variable", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, []);
8 |
9 | expect(exitCode).toBe(0);
10 | expect(stderr).toBeFalsy();
11 | expect(stdout).toContain("PASS");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/build/bundle-variable/bundle-variable.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { run } = require("../../utils/test-utils");
4 |
5 | describe("bundle variable", () => {
6 | it("compiles without flags and export variable", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, []);
8 |
9 | expect(exitCode).toBe(0);
10 | expect(stderr).toBeFalsy();
11 | expect(stdout).toContain("PASS");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/build/config-format/babel-commonjs/babel-esm.test.js:
--------------------------------------------------------------------------------
1 | const { run } = require("../../../utils/test-utils");
2 |
3 | describe("webpack cli", () => {
4 | it("should support mjs config format", async () => {
5 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "webpack.config.babel.js"]);
6 |
7 | expect(exitCode).toBe(0);
8 | expect(stderr).toBeFalsy();
9 | expect(stdout).toBeTruthy();
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/test/build/config-format/commonjs-default/commonjs-default.test.js:
--------------------------------------------------------------------------------
1 | const { run } = require("../../../utils/test-utils");
2 |
3 | describe("webpack cli", () => {
4 | it("should support CommonJS file", async () => {
5 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "webpack.config.cjs"]);
6 |
7 | expect(exitCode).toBe(0);
8 | expect(stderr).toBeFalsy();
9 | expect(stdout).toBeTruthy();
10 | });
11 | });
12 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => {
2 | console.log("derived.webpack.config.js");
3 |
4 | return [
5 | {
6 | name: "derived_config1",
7 | extends: "./base.webpack.config.js",
8 | entry: "./src/index1.js",
9 | },
10 | {
11 | name: "derived_config2",
12 | extends: "./base.webpack.config.js",
13 | entry: "./src/index2.js",
14 | },
15 | ];
16 | };
17 |
--------------------------------------------------------------------------------
/test/build/name/name.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { run } = require("../../utils/test-utils");
4 |
5 | describe("name flag", () => {
6 | it("should set the flag in the config", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["--name", "config-name"]);
8 |
9 | expect(exitCode).toBe(0);
10 | expect(stderr).toBeFalsy();
11 | expect(stdout).toContain("name: 'config-name'");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/index.html.tpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | React webpack Project
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/default/package.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "version": "1.0.0",
3 |
4 | "description": "My webpack project",
5 |
6 | "name": "webpack-project",
7 | "scripts": {
8 | "build": "webpack --mode=production --node-env=production",
9 | "build:dev": "webpack --mode=development",
10 | <% if (devServer) { %>
11 | "serve": "webpack serve",
12 | <% } %>
13 | "watch": "webpack --watch"
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/test/serve/basic/output-public-path.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | devtool: false,
6 | output: {
7 | publicPath: "/my-public-path/",
8 | },
9 | plugins: [new WebpackCLITestPlugin(["mode", "output"], false, "hooks.compilation.taps")],
10 | devServer: {
11 | client: {
12 | logging: "info",
13 | },
14 | },
15 | };
16 |
--------------------------------------------------------------------------------
/test/serve/basic/function-with-env.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = (env) => {
4 | console.log(env);
5 |
6 | return {
7 | mode: "development",
8 | devtool: false,
9 | plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")],
10 | devServer: {
11 | client: {
12 | logging: "info",
13 | },
14 | },
15 | };
16 | };
17 |
--------------------------------------------------------------------------------
/test/serve/basic/function-with-argv.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = (env, argv) => {
4 | console.log(argv);
5 |
6 | return {
7 | mode: "development",
8 | devtool: false,
9 | plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")],
10 | devServer: {
11 | client: {
12 | logging: "info",
13 | },
14 | },
15 | };
16 | };
17 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs2/base.webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => {
4 | console.log("base.webpack.config.js");
5 |
6 | return {
7 | entry: "./src/index1.js",
8 | name: "base_config",
9 | mode: "development",
10 | plugins: [new WebpackCLITestPlugin()],
11 |
12 | experiments: {
13 | topLevelAwait: true,
14 | },
15 | };
16 | };
17 |
--------------------------------------------------------------------------------
/packages/webpack-cli/src/utils/dynamic-import-loader.ts:
--------------------------------------------------------------------------------
1 | import { type DynamicImport } from "../types.js";
2 |
3 | function dynamicImportLoader(): DynamicImport | null {
4 | let importESM;
5 |
6 | try {
7 | // eslint-disable-next-line no-new-func
8 | importESM = new Function("id", "return import(id);");
9 | } catch {
10 | importESM = null;
11 | }
12 |
13 | return importESM as DynamicImport;
14 | }
15 |
16 | module.exports = dynamicImportLoader;
17 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-no-configuration/__snapshots__/without-config-path-no-configuration.test.js.snap.webpack5:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2 |
3 | exports[`'configtest' command without the configuration path option should validate default configuration: stderr 1`] = `"[webpack-cli] No configuration found."`;
4 |
5 | exports[`'configtest' command without the configuration path option should validate default configuration: stdout 1`] = `""`;
6 |
--------------------------------------------------------------------------------
/.github/workflows/dependency-review.yml:
--------------------------------------------------------------------------------
1 | name: "Dependency Review"
2 | on: [pull_request]
3 |
4 | permissions:
5 | contents: read
6 |
7 | jobs:
8 | dependency-review:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: "Checkout Repository"
12 | uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
13 | - name: "Dependency Review"
14 | uses: actions/dependency-review-action@3c4e3dcb1aa7874d2c16be7d79418e9b7efd6261 # v4.8.2
15 |
--------------------------------------------------------------------------------
/test/build/config/function/multi-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => [
2 | {
3 | output: {
4 | filename: "./dist-first.js",
5 | },
6 | name: "first",
7 | entry: "./src/first.js",
8 | mode: "development",
9 | stats: "minimal",
10 | },
11 | {
12 | output: {
13 | filename: "./dist-second.js",
14 | },
15 | name: "second",
16 | entry: "./src/second.js",
17 | mode: "development",
18 | stats: "minimal",
19 | },
20 | ];
21 |
--------------------------------------------------------------------------------
/test/build/bail/bail-multi-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | devtool: false,
4 | output: {
5 | filename: "./dist-first.js",
6 | },
7 | name: "first",
8 | entry: "./src/first.js",
9 | mode: "development",
10 | bail: true,
11 | },
12 | {
13 | devtool: false,
14 | output: {
15 | filename: "./dist-second.js",
16 | },
17 | name: "second",
18 | entry: "./src/second.js",
19 | mode: "development",
20 | },
21 | ];
22 |
--------------------------------------------------------------------------------
/test/build/target/node/node-test.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { normalizeStderr, run } = require("../../../utils/test-utils");
4 |
5 | describe("Node target", () => {
6 | it("should emit the correct code", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.js"]);
8 |
9 | expect(exitCode).toBe(0);
10 | expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
11 | expect(stdout).toBeTruthy();
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/serve/basic/dev-server-output-public-path.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 | const { devServerConfig } = require("./helper/base-dev-server.config");
3 |
4 | module.exports = {
5 | mode: "development",
6 | devtool: false,
7 | output: {
8 | publicPath: "/my-public-path/",
9 | },
10 | devServer: devServerConfig,
11 | plugins: [new WebpackCLITestPlugin(["mode", "output"], false, "hooks.compilation.taps")],
12 | };
13 |
--------------------------------------------------------------------------------
/test/watch/bail/bail-multi-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | devtool: false,
4 | output: {
5 | filename: "./dist-first.js",
6 | },
7 | name: "first",
8 | entry: "./src/first.js",
9 | mode: "development",
10 | bail: true,
11 | },
12 | {
13 | devtool: false,
14 | output: {
15 | filename: "./dist-second.js",
16 | },
17 | name: "second",
18 | entry: "./src/second.js",
19 | mode: "development",
20 | },
21 | ];
22 |
--------------------------------------------------------------------------------
/test/build/config/type/function-array/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = () => [
4 | {
5 | entry: "./a",
6 | name: "first",
7 | output: {
8 | path: path.resolve(__dirname, "./binary"),
9 | filename: "a-functor.js",
10 | },
11 | },
12 | {
13 | entry: "./b",
14 | name: "second",
15 | output: {
16 | path: path.resolve(__dirname, "./binary"),
17 | filename: "b-functor.js",
18 | },
19 | },
20 | ];
21 |
--------------------------------------------------------------------------------
/test/build/extends/multiple-configs2/webpack.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = () => {
4 | console.log("derived.webpack.config.js");
5 |
6 | return [
7 | {
8 | extends: "./base.webpack.config.js",
9 | },
10 | {
11 | name: "derived_config2",
12 | mode: "development",
13 | entry: "./src/index2.js",
14 | plugins: [new WebpackCLITestPlugin()],
15 | },
16 | ];
17 | };
18 |
--------------------------------------------------------------------------------
/test/watch/stats/webpack.config.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 |
3 | module.exports = {
4 | watch: true,
5 | stats: "none",
6 | mode: "development",
7 | plugins: [
8 | {
9 | apply(compiler) {
10 | (compiler.webpack ? compiler.hooks.afterDone : compiler.hooks.done).tap(
11 | "webpack-cli-test",
12 | () => {
13 | console.log(`webpack ${webpack.version}`);
14 | },
15 | );
16 | },
17 | },
18 | ],
19 | };
20 |
--------------------------------------------------------------------------------
/test/build/bail/multi-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | devtool: false,
4 | output: {
5 | filename: "./dist-first.js",
6 | },
7 | name: "first",
8 | entry: "./src/first.js",
9 | mode: "development",
10 | bail: true,
11 | watch: true,
12 | },
13 | {
14 | devtool: false,
15 | output: {
16 | filename: "./dist-second.js",
17 | },
18 | name: "second",
19 | entry: "./src/second.js",
20 | mode: "development",
21 | },
22 | ];
23 |
--------------------------------------------------------------------------------
/test/build/config/type/array-functions/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = [
4 | () => ({
5 | entry: "./a",
6 | name: "first",
7 | output: {
8 | path: path.resolve(__dirname, "./binary"),
9 | filename: "a-functor.js",
10 | },
11 | }),
12 | () => ({
13 | entry: "./b",
14 | name: "second",
15 | output: {
16 | path: path.resolve(__dirname, "./binary"),
17 | filename: "b-functor.js",
18 | },
19 | }),
20 | ];
21 |
--------------------------------------------------------------------------------
/test/build/entry/defaults-empty/entry-single-arg.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { run } = require("../../../utils/test-utils");
4 |
5 | describe("single entry flag empty project", () => {
6 | it("sets default entry, compiles but throw missing module error", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname);
8 |
9 | expect(exitCode).toBe(1);
10 | expect(stderr).toBeFalsy();
11 | expect(stdout).toContain("not found: Error: Can't resolve");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/watch/bail/multi-webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | devtool: false,
4 | output: {
5 | filename: "./dist-first.js",
6 | },
7 | name: "first",
8 | entry: "./src/first.js",
9 | mode: "development",
10 | bail: true,
11 | watch: true,
12 | },
13 | {
14 | devtool: false,
15 | output: {
16 | filename: "./dist-second.js",
17 | },
18 | name: "second",
19 | entry: "./src/second.js",
20 | mode: "development",
21 | },
22 | ];
23 |
--------------------------------------------------------------------------------
/test/api/resolve-config/webpack.config.cjs:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | output: {
4 | filename: "./dist-amd.js",
5 | libraryTarget: "amd",
6 | },
7 | entry: "./a.js",
8 | name: "amd",
9 | mode: "development",
10 | devtool: "eval-cheap-module-source-map",
11 | },
12 | {
13 | output: {
14 | filename: "./dist-commonjs.js",
15 | libraryTarget: "commonjs",
16 | },
17 | entry: "./a.js",
18 | mode: "production",
19 | target: "node",
20 | },
21 | ];
22 |
--------------------------------------------------------------------------------
/test/api/capitalizeFirstLetter.test.js:
--------------------------------------------------------------------------------
1 | const CLI = require("../../packages/webpack-cli/lib/webpack-cli");
2 |
3 | describe("capitalizeFirstLetter", () => {
4 | it("should capitalize first letter", () => {
5 | const cli = new CLI();
6 |
7 | expect(cli.capitalizeFirstLetter("webpack")).toBe("Webpack");
8 | });
9 |
10 | it("should return an empty string on passing a non-string value", () => {
11 | const cli = new CLI();
12 |
13 | expect(cli.capitalizeFirstLetter(true)).toBe("");
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/test/utils/cli-plugin-test/webpack.config.js:
--------------------------------------------------------------------------------
1 | // webpack.config.js
2 | const { cli } = require("webpack");
3 | const WebpackCLITestPlugin = require("../webpack-cli-test-plugin");
4 |
5 | module.exports = {
6 | entry: "./main.js",
7 | mode: "development",
8 | target: "node",
9 | resolve: {
10 | alias:
11 | typeof cli !== "undefined"
12 | ? {
13 | alias: ["alias1", "alias2"],
14 | }
15 | : {},
16 | },
17 | plugins: [new WebpackCLITestPlugin(["resolve"])],
18 | };
19 |
--------------------------------------------------------------------------------
/smoketests/missing-packages/webpack-bundle-analyzer.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { runTest } = require("../helpers");
4 |
5 | const webpackBundleAnalyzerTest = () => {
6 | const packageName = "webpack-bundle-analyzer";
7 | const args = ["--analyze"];
8 | const logMessage = "It looks like webpack-bundle-analyzer is not installed.";
9 |
10 | return runTest(packageName, args, logMessage);
11 | };
12 |
13 | module.exports.name = "Missing webpack-bundle-analyzer";
14 | module.exports.run = [webpackBundleAnalyzerTest];
15 |
--------------------------------------------------------------------------------
/test/watch/analyze/analyze-flag.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { runWatch } = require("../../utils/test-utils");
4 |
5 | describe('"analyze" option', () => {
6 | it("should load webpack-bundle-analyzer plugin with --analyze flag", async () => {
7 | const { stderr, stdout } = await runWatch(__dirname, ["--analyze"], {
8 | killString: /Webpack Bundle Analyzer is started at/,
9 | });
10 |
11 | expect(stderr).toBeFalsy();
12 | expect(stdout).toContain("Webpack Bundle Analyzer is started at");
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/components/About.jsx.tpl:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import webpackLogo from "../assets/webpack.png";
3 |
4 | const About = ({ msg }) => {
5 | return (
6 |
7 |
8 |

9 |
This is the About page!
10 |
11 | This is a webpack + {msg} project.
12 |
13 |
14 |
15 | );
16 | }
17 |
18 | export default About;
19 |
--------------------------------------------------------------------------------
/test/build/zero-config/entry-absent/zero-config.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { run } = require("../../../utils/test-utils");
4 |
5 | describe("Zero Config tests", () => {
6 | it("runs when config and entry are both absent", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, []);
8 |
9 | expect(exitCode).toBe(1);
10 | expect(stderr).toBeFalsy();
11 | // Entry file is absent, should log the Error from the compiler
12 | expect(stdout).toContain("Error: Can't resolve './src'");
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/plugin/default/src/index.js.tpl:
--------------------------------------------------------------------------------
1 | /**
2 | * See the webpack docs for more information about plugins:
3 | * https://webpack.js.org/contribute/writing-a-plugin/#basic-plugin-architecture
4 | */
5 |
6 | class <%= pluginIdentifier %> {
7 | apply(compiler) {
8 | compiler.hooks.done.tap('<%= name %>', (
9 | stats /* stats is passed as an argument when done hook is tapped. */
10 | ) => {
11 | console.log('Hello World!');
12 | });
13 | }
14 | }
15 |
16 | module.exports = <%= pluginIdentifier %>;
17 |
--------------------------------------------------------------------------------
/test/build/config/object-freeze/index.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config with `Object.freeze({})`", () => {
7 | it("should not throw error", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/serve/basic/same-ports-dev-server.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | name: "one",
4 | mode: "development",
5 | devtool: false,
6 | output: {
7 | filename: "first-output/[name].js",
8 | },
9 | devServer: {
10 | port: 8081,
11 | },
12 | },
13 | {
14 | name: "two",
15 | mode: "development",
16 | devtool: false,
17 | entry: "./src/other.js",
18 | output: {
19 | filename: "second-output/[name].js",
20 | },
21 | devServer: {
22 | port: 8081,
23 | },
24 | },
25 | ];
26 |
--------------------------------------------------------------------------------
/test/build/colors/multi-stats-colors.webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | name: "first-config",
4 | entry: "./src/first.js",
5 | stats: {
6 | colors: {
7 | green: "\u001B[31m", // overwriting with red for test
8 | },
9 | },
10 | mode: "development",
11 | },
12 | {
13 | name: "second-config",
14 | entry: "./src/second.js",
15 | stats: {
16 | colors: {
17 | green: "\u001B[34m", // overwriting with blue for test
18 | },
19 | },
20 | mode: "development",
21 | },
22 | ];
23 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/tsconfig.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "@tsconfig/svelte/tsconfig.json",
3 | "compilerOptions": {
4 | "target": "es5",
5 | "module": "es6",
6 | "strict": true,
7 | "moduleResolution": "node",
8 | "skipLibCheck": true,
9 | "esModuleInterop": true,
10 | "allowSyntheticDefaultImports": true,
11 | "sourceMap": true,
12 | },
13 | "include": [
14 | "src/**/*.ts",
15 | "src/**/*.js",
16 | "src/**/*.svelte"
17 | ],
18 | "exclude": [
19 | "node_modules"
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/test/build/config-lookup/dotfolder-array/.webpack/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | output: {
4 | filename: "./dist-amd.js",
5 | libraryTarget: "amd",
6 | },
7 | name: "amd",
8 | entry: "./a.js",
9 | mode: "development",
10 | devtool: "eval-cheap-module-source-map",
11 | },
12 | {
13 | output: {
14 | filename: "./dist-commonjs.js",
15 | libraryTarget: "commonjs",
16 | },
17 | name: "commonjs",
18 | entry: "./a.js",
19 | mode: "development",
20 | target: "node",
21 | },
22 | ];
23 |
--------------------------------------------------------------------------------
/test/build/config/error-array/config-array-error.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { run } = require("../../../utils/test-utils");
4 |
5 | describe("config with invalid array syntax", () => {
6 | it("should throw syntax error and exit with non-zero exit code when even 1 object has syntax error", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.js"]);
8 | expect(exitCode).toBe(2);
9 | expect(stderr).toContain("SyntaxError: Unexpected token");
10 | expect(stdout).toBeFalsy();
11 | });
12 | });
13 |
--------------------------------------------------------------------------------
/test/build/config-format/failure/failure.test.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | const { run } = require("../../../utils/test-utils");
4 |
5 | describe("failure", () => {
6 | it("should log error on not installed registers", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "webpack.config.iced"]);
8 |
9 | expect(exitCode).toBe(2);
10 | expect(stderr).toContain(
11 | `Failed to load '${path.resolve(__dirname, "./webpack.config.iced")}'`,
12 | );
13 | expect(stdout).toBeFalsy();
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/test/build/config/object-freeze-partial/index.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config with partial `Object.freeze({})`", () => {
7 | it("should not throw error", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/index.jsx.tpl:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { createRoot } from 'react-dom/client';
3 | import App from './App';
4 | <% if (cssType == 'CSS only') { %>
5 | import "./styles/global.css";<% } if (cssType == 'SASS') { %>
6 | import "./styles/global.scss";<% } if (cssType == 'LESS') { %>
7 | import "./styles/global.less";<% } if (cssType == 'Stylus') { %>
8 | import "./styles/global.styl";<% } %>
9 |
10 | const container = document.getElementById('root');
11 | const root = createRoot(container);
12 | root.render();
13 |
--------------------------------------------------------------------------------
/test/create-webpack-app/loader/error-test/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = {
4 | mode: "development",
5 |
6 | entry: {
7 | bundle: "./src/index.ts",
8 | },
9 |
10 | output: {
11 | path: path.resolve(__dirname, "dist"),
12 | filename: "[name].js",
13 | },
14 |
15 | module: {
16 | rules: [
17 | {
18 | test: /.(ts|tsx)?$/,
19 | loader: "ts-loader",
20 | include: [path.resolve(__dirname, "src")],
21 | exclude: [/node_modules/],
22 | },
23 | ],
24 | },
25 | };
26 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path/__snapshots__/without-config-path.test.js.snap.webpack5:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2 |
3 | exports[`'configtest' command without the configuration path option should validate default configuration: stderr 1`] = `""`;
4 |
5 | exports[`'configtest' command without the configuration path option should validate default configuration: stdout 1`] = `
6 | "[webpack-cli] Validate '/test/configtest/without-config-path/webpack.config.js'.
7 | [webpack-cli] There are no validation errors in the given webpack configuration."
8 | `;
9 |
--------------------------------------------------------------------------------
/packages/webpack-cli/src/bootstrap.ts:
--------------------------------------------------------------------------------
1 | import { type IWebpackCLI } from "./types.js";
2 | import WebpackCLI from "./webpack-cli.js";
3 |
4 | const runCLI = async (args: Parameters[0]) => {
5 | // Create a new instance of the CLI object
6 | const cli: IWebpackCLI = new WebpackCLI();
7 |
8 | try {
9 | await cli.run(args);
10 | } catch (error) {
11 | cli.logger.error(error);
12 | process.exit(2);
13 | }
14 | };
15 |
16 | export default runCLI;
17 |
18 | // TODO remove me in the next major release and use `default` export
19 | module.exports = runCLI;
20 |
--------------------------------------------------------------------------------
/test/build/config-name/function-config.js:
--------------------------------------------------------------------------------
1 | module.exports = () => [
2 | {
3 | output: {
4 | filename: "./dist-first.js",
5 | },
6 | name: "first",
7 | entry: "./src/first.js",
8 | mode: "development",
9 | },
10 | {
11 | output: {
12 | filename: "./dist-second.js",
13 | },
14 | name: "second",
15 | entry: "./src/second.js",
16 | mode: "development",
17 | },
18 | {
19 | output: {
20 | filename: "./dist-third.js",
21 | },
22 | name: "third",
23 | entry: "./src/third.js",
24 | mode: "none",
25 | },
26 | ];
27 |
--------------------------------------------------------------------------------
/test/build/config/no-code/no-code.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config flag with no code", () => {
7 | it("should build and not throw error with no configuration or index file", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/index.tsx.tpl:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { createRoot } from 'react-dom/client';
3 | import App from './App';
4 | <% if (cssType == 'CSS only') { %>
5 | import "./styles/global.css";<% } if (cssType == 'SASS') { %>
6 | import "./styles/global.scss";<% } if (cssType == 'LESS') { %>
7 | import "./styles/global.less";<% } if (cssType == 'Stylus') { %>
8 | import "./styles/global.styl";<% } %>
9 |
10 | const container = document.getElementById('root') as HTMLElement;
11 | const root = createRoot(container);
12 | root.render();
13 |
--------------------------------------------------------------------------------
/test/build/cache/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = {
4 | mode: "development",
5 | name: "cache-test-default",
6 | cache: {
7 | type: "filesystem",
8 | buildDependencies: {
9 | config: [__filename],
10 | },
11 | },
12 | infrastructureLogging: {
13 | debug: /cache/,
14 | },
15 | entry: {
16 | app: "./src/main.js",
17 | },
18 | output: {
19 | filename: "[name].bundle.js",
20 | chunkFilename: "[name].bundle.js",
21 | path: path.resolve(__dirname, "dist"),
22 | publicPath: "/",
23 | },
24 | };
25 |
--------------------------------------------------------------------------------
/test/build/config/empty/empty.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config flag with empty config file", () => {
7 | it("should build and not throw error with no configuration or index file", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/build/config/no-config-array/no-config-array.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config with empty array", () => {
7 | it("should build and not throw error with empty configuration", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeFalsy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/build/config/type/array-function-with-argv/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | (env, argv) => {
3 | const { mode } = argv;
4 | return {
5 | entry: "./a.js",
6 | name: "first",
7 | output: {
8 | filename: mode === "production" ? "a-prod.js" : "a-dev.js",
9 | },
10 | };
11 | },
12 | (env, argv) => {
13 | const { mode } = argv;
14 | return {
15 | entry: "./b.js",
16 | name: "second",
17 | output: {
18 | filename: mode === "production" ? "b-prod.js" : "b-dev.js",
19 | },
20 | };
21 | },
22 | ];
23 |
--------------------------------------------------------------------------------
/test/build/config/type/array-function-with-env/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | (env, argv) => {
3 | const { mode } = argv;
4 | return {
5 | entry: "./a.js",
6 | name: "first",
7 | output: {
8 | filename: mode === "production" ? "a-prod.js" : "a-dev.js",
9 | },
10 | };
11 | },
12 | (env, argv) => {
13 | const { mode } = argv;
14 | return {
15 | entry: "./b.js",
16 | name: "second",
17 | output: {
18 | filename: mode === "production" ? "b-prod.js" : "b-dev.js",
19 | },
20 | };
21 | },
22 | ];
23 |
--------------------------------------------------------------------------------
/test/build/config/type/promise-array/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = new Promise((resolve) => {
4 | setTimeout(() => {
5 | resolve([
6 | {
7 | entry: "./a",
8 | output: {
9 | path: path.resolve(__dirname, "./binary"),
10 | filename: "a-promise.js",
11 | },
12 | },
13 | {
14 | entry: "./b",
15 | output: {
16 | path: path.resolve(__dirname, "./binary"),
17 | filename: "b-promise.js",
18 | },
19 | },
20 | ]);
21 | }, 0);
22 | });
23 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path/without-config-path.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { normalizeStderr, normalizeStdout, run } = require("../../utils/test-utils");
4 |
5 | describe("'configtest' command without the configuration path option", () => {
6 | it("should validate default configuration", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["configtest"]);
8 |
9 | expect(exitCode).toBe(0);
10 | expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
11 | expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/create-webpack-app/loader/warning-test/loader-warning.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { createPathDependentUtils } = require("../../test.utils");
4 |
5 | const { run } = createPathDependentUtils("webpack-cli");
6 |
7 | describe("loader warning test", () => {
8 | it("should not ignore loader's warning and exit with a non zero exit code", async () => {
9 | const { stdout, exitCode } = await run(__dirname, [], false);
10 |
11 | expect(stdout).toContain("[1 warning]");
12 | expect(stdout).toContain("This is a warning");
13 | expect(exitCode).toBe(0);
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/test/build/config/named-export/mjs.test.js:
--------------------------------------------------------------------------------
1 | const { run } = require("../../../utils/test-utils");
2 |
3 | describe("webpack cli", () => {
4 | it("should support mjs config format", async () => {
5 | const { exitCode, stderr } = await run(__dirname, ["-c", "webpack.config.mjs"], {
6 | env: { WEBPACK_CLI_FORCE_LOAD_ESM_CONFIG: true },
7 | });
8 |
9 | if (/Error: Not supported/.test(stderr)) {
10 | expect(exitCode).toBe(2);
11 | } else {
12 | expect(exitCode).toBe(2);
13 | expect(stderr).toMatch(/Unable to find default export./);
14 | }
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/test/build/config/type/array/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | output: {
4 | filename: "./dist-amd.js",
5 | libraryTarget: "amd",
6 | },
7 | name: "amd",
8 | entry: "./a.js",
9 | mode: "development",
10 | stats: "verbose",
11 | devtool: "eval-cheap-module-source-map",
12 | },
13 | {
14 | output: {
15 | filename: "./dist-commonjs.js",
16 | libraryTarget: "commonjs",
17 | },
18 | name: "commonjs",
19 | entry: "./a.js",
20 | mode: "development",
21 | stats: "detailed",
22 | target: "node",
23 | },
24 | ];
25 |
--------------------------------------------------------------------------------
/test/build/config/undefined/undefined.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config flag with undefined export config file", () => {
7 | it("should not throw error with no configuration or index file", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/build/core-flags/warning.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = {
4 | mode: "development",
5 | entry: "./src/main.js",
6 | module: {
7 | rules: [
8 | {
9 | test: /.(js|jsx)?$/,
10 | loader: "my-warning-loader",
11 | include: [path.resolve(__dirname, "src")],
12 | exclude: [/node_modules/],
13 | },
14 | ],
15 | },
16 | resolveLoader: {
17 | alias: {
18 | "my-warning-loader": require.resolve("./my-warning-loader"),
19 | },
20 | },
21 | performance: {
22 | hints: "warning",
23 | },
24 | };
25 |
--------------------------------------------------------------------------------
/test/build/output/__snapshots__/output-named-bundles.test.js.snap.webpack5:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2 |
3 | exports[`output flag named bundles should output file in bin directory using default webpack config with warning for empty output value: stderr 1`] = `
4 | "[webpack-cli] Error: Option '-o, --output-path ' argument missing
5 | [webpack-cli] Run 'webpack --help' to see available commands and options"
6 | `;
7 |
8 | exports[`output flag named bundles should output file in bin directory using default webpack config with warning for empty output value: stdout 1`] = `""`;
9 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-error/without-config-path-error.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { normalizeStderr, normalizeStdout, run } = require("../../utils/test-utils");
4 |
5 | describe("'configtest' command without the configuration path option", () => {
6 | it("should validate default configuration", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["configtest"]);
8 |
9 | expect(exitCode).toBe(2);
10 | expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
11 | expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/build/config-name/webpack.config.js:
--------------------------------------------------------------------------------
1 | module.exports = [
2 | {
3 | output: {
4 | filename: "./dist-first.js",
5 | },
6 | name: "first",
7 | entry: "./src/first.js",
8 | mode: "development",
9 | },
10 | {
11 | output: {
12 | filename: "./dist-second.js",
13 | },
14 | name: "second",
15 | entry: "./src/second.js",
16 | mode: "development",
17 | },
18 | {
19 | output: {
20 | filename: "./dist-third.js",
21 | },
22 | name: "third",
23 | entry: "./src/third.js",
24 | mode: "none",
25 | stats: "verbose",
26 | },
27 | ];
28 |
--------------------------------------------------------------------------------
/test/build/zero-config/entry-present/zero-config.test.js:
--------------------------------------------------------------------------------
1 | const { run } = require("../../../utils/test-utils");
2 |
3 | describe("Zero Config tests", () => {
4 | it("runs when no config is supplied but entry is present", async () => {
5 | const { exitCode, stderr, stdout } = await run(__dirname, []);
6 |
7 | expect(exitCode).toBe(0);
8 | expect(stderr).toBeFalsy();
9 | // Should be able to find the entry file
10 | expect(stdout).toContain("./src/index.js");
11 | // Should output at the default output dir and filename
12 | expect(stdout).toContain("main.js");
13 | });
14 | });
15 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-custom-extension/without-config-path.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { normalizeStderr, normalizeStdout, run } = require("../../utils/test-utils");
4 |
5 | describe("'configtest' command without the configuration path option", () => {
6 | it("should validate default configuration", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["configtest"]);
8 |
9 | expect(exitCode).toBe(0);
10 | expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
11 | expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-custom-extension/__snapshots__/without-config-path.test.js.snap.webpack5:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2 |
3 | exports[`'configtest' command without the configuration path option should validate default configuration: stderr 1`] = `""`;
4 |
5 | exports[`'configtest' command without the configuration path option should validate default configuration: stdout 1`] = `
6 | "[webpack-cli] Validate '/test/configtest/without-config-path-custom-extension/webpack.config.json'.
7 | [webpack-cli] There are no validation errors in the given webpack configuration."
8 | `;
9 |
--------------------------------------------------------------------------------
/test/serve/basic/dev-server-false.multi.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 |
3 | module.exports = [
4 | {
5 | name: "app",
6 | dependencies: ["worker"],
7 | mode: "development",
8 | devtool: false,
9 | target: "web",
10 | entry: "./src/index.js",
11 | plugins: [new WebpackCLITestPlugin(["mode"], false, "hooks.compilation.taps")],
12 | },
13 | {
14 | name: "worker",
15 | mode: "development",
16 | devtool: false,
17 | target: "webworker",
18 | entry: "./src/worker.js",
19 | devServer: false,
20 | },
21 | ];
22 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/router/index.jsx.tpl:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
3 | import Home from '../components/Home';
4 | import About from '../components/About';
5 | import Navbar from '../components/Navbar';
6 |
7 | function AppRouter() {
8 | return (
9 |
10 |
11 |
12 | } />
13 | } />
14 |
15 |
16 | );
17 | }
18 |
19 | export default AppRouter;
20 |
--------------------------------------------------------------------------------
/test/build/config/empty-array/empty-array.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config flag with config file returning empty array", () => {
7 | it("should build and not throw error with no configuration or index file", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/build/config/empty-promise/empty-promise.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config file with promise resolving empty object", () => {
7 | it("should build and not throw error with no configuration or index file", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/components/About.tsx.tpl:
--------------------------------------------------------------------------------
1 | import React from "react";
2 | import webpackLogo from "../assets/webpack.png";
3 |
4 | interface Props {
5 | msg: string;
6 | }
7 |
8 | const About: React.FC = (props: Props) => {
9 | return (
10 |
11 |
12 |

13 |
This is the About page!
14 |
15 | This is a webpack + {props.msg} project.
16 |
17 |
18 |
19 | );
20 | }
21 |
22 | export default About;
23 |
--------------------------------------------------------------------------------
/test/build/config/basic/basic-config.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("basic config file", () => {
7 | it("should build and not throw error with a basic configuration file", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | "--output-path",
12 | "./binary",
13 | ]);
14 | expect(exitCode).toBe(0);
15 | expect(stderr).toBeFalsy();
16 | expect(stdout).toBeTruthy();
17 | });
18 | });
19 |
--------------------------------------------------------------------------------
/test/build/config/empty-function/empty-function.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config file with function returning empty object", () => {
7 | it("should build and not throw error with no configuration or index file", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/build/config/undefined-default/undefined-default.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config flag with undefined default export config file", () => {
7 | it("should not throw error with no configuration or index file", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(stdout).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/build/stats/flags/__snapshots__/stats.test.js.snap.webpack5:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2 |
3 | exports[`stats flag should log error when an unknown flag stats value is passed: stderr 1`] = `
4 | "[webpack-cli] Invalid value 'foo' for the '--stats' option
5 | [webpack-cli] Expected: 'none | summary | errors-only | errors-warnings | minimal | normal | detailed | verbose'
6 | [webpack-cli] Invalid value 'foo' for the '--stats' option
7 | [webpack-cli] Expected: 'true | false'"
8 | `;
9 |
10 | exports[`stats flag should log error when an unknown flag stats value is passed: stdout 1`] = `""`;
11 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-no-configuration/without-config-path-no-configuration.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { normalizeStderr, normalizeStdout, run } = require("../../utils/test-utils");
4 |
5 | describe("'configtest' command without the configuration path option", () => {
6 | it("should validate default configuration", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["configtest"]);
8 |
9 | expect(exitCode).toBe(2);
10 | expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
11 | expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-multi-compiler-mode/without-config-path-multi-compiler-mode.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { normalizeStderr, normalizeStdout, run } = require("../../utils/test-utils");
4 |
5 | describe("'configtest' command without the configuration path option", () => {
6 | it("should validate default configuration", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, ["configtest"]);
8 |
9 | expect(exitCode).toBe(0);
10 | expect(normalizeStderr(stderr)).toMatchSnapshot("stderr");
11 | expect(normalizeStdout(stdout)).toMatchSnapshot("stdout");
12 | });
13 | });
14 |
--------------------------------------------------------------------------------
/test/watch/watch-variable/webpack.config.js:
--------------------------------------------------------------------------------
1 | const isInProcess = process.env.WEBPACK_WATCH;
2 |
3 | class CustomTestPlugin {
4 | constructor(isInEnvironment) {
5 | this.isInEnvironment = isInEnvironment;
6 | }
7 |
8 | apply(compiler) {
9 | compiler.hooks.done.tap("testPlugin", () => {
10 | if (!isInProcess && this.isInEnvironment) {
11 | console.log("PASS");
12 | } else {
13 | console.log("FAIL");
14 | }
15 | });
16 | }
17 | }
18 |
19 | module.exports = (env) => ({
20 | mode: "development",
21 | devtool: false,
22 | plugins: [new CustomTestPlugin(env.WEBPACK_WATCH)],
23 | });
24 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/src/plopfile.ts:
--------------------------------------------------------------------------------
1 | import { type NodePlopAPI } from "node-plop";
2 |
3 | export default async function plopfile(plop: NodePlopAPI) {
4 | // init generators
5 | await plop.load("./generators/init/default.js", {}, true);
6 | await plop.load("./generators/init/react.js", {}, true);
7 | await plop.load("./generators/init/vue.js", {}, true);
8 | await plop.load("./generators/init/svelte.js", {}, true);
9 |
10 | // loader generators
11 | await plop.load("./generators/loader/default.js", {}, true);
12 |
13 | // plugin generators
14 | await plop.load("./generators/plugin/default.js", {}, true);
15 | }
16 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/src/router/index.tsx.tpl:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 | import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
3 | import Home from '../components/Home';
4 | import About from '../components/About';
5 | import Navbar from '../components/Navbar';
6 |
7 | const AppRouter: React.FC = () => {
8 | return (
9 |
10 |
11 |
12 | } />
13 | } />
14 |
15 |
16 | );
17 | };
18 |
19 | export default AppRouter;
20 |
--------------------------------------------------------------------------------
/test/build/build-variable/webpack.config.js:
--------------------------------------------------------------------------------
1 | const isInProcess = process.env.WEBPACK_BUNDLE;
2 |
3 | class CustomTestPlugin {
4 | constructor(isInEnvironment) {
5 | this.isInEnvironment = isInEnvironment;
6 | }
7 |
8 | apply(compiler) {
9 | compiler.hooks.done.tap("testPlugin", () => {
10 | if (!isInProcess && this.isInEnvironment) {
11 | console.log("PASS");
12 | } else {
13 | console.log("FAIL");
14 | }
15 | });
16 | }
17 | }
18 |
19 | module.exports = (env) => ({
20 | mode: "development",
21 | devtool: false,
22 | plugins: [new CustomTestPlugin(env.WEBPACK_BUILD)],
23 | });
24 |
--------------------------------------------------------------------------------
/test/build/bundle-variable/webpack.config.js:
--------------------------------------------------------------------------------
1 | const isInProcess = process.env.WEBPACK_BUNDLE;
2 |
3 | class CustomTestPlugin {
4 | constructor(isInEnvironment) {
5 | this.isInEnvironment = isInEnvironment;
6 | }
7 |
8 | apply(compiler) {
9 | compiler.hooks.done.tap("testPlugin", () => {
10 | if (!isInProcess && this.isInEnvironment) {
11 | console.log("PASS");
12 | } else {
13 | console.log("FAIL");
14 | }
15 | });
16 | }
17 | }
18 |
19 | module.exports = (env) => ({
20 | mode: "development",
21 | devtool: false,
22 | plugins: [new CustomTestPlugin(env.WEBPACK_BUNDLE)],
23 | });
24 |
--------------------------------------------------------------------------------
/test/build/config/no-config-object/no-config-object.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("empty config", () => {
7 | it("should build and not throw error with empty object as configuration", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | "--mode",
12 | "development",
13 | ]);
14 |
15 | expect(exitCode).toBe(0);
16 | expect(stderr).toBeFalsy();
17 | expect(stdout).toBeTruthy();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/test/configtest/without-config-path-multi-compiler-mode/__snapshots__/without-config-path-multi-compiler-mode.test.js.snap.webpack5:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2 |
3 | exports[`'configtest' command without the configuration path option should validate default configuration: stderr 1`] = `""`;
4 |
5 | exports[`'configtest' command without the configuration path option should validate default configuration: stdout 1`] = `
6 | "[webpack-cli] Validate '/test/configtest/without-config-path-multi-compiler-mode/webpack.config.js'.
7 | [webpack-cli] There are no validation errors in the given webpack configuration."
8 | `;
9 |
--------------------------------------------------------------------------------
/test/build/config/type/promise/promise.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe("promise", () => {
8 | it("is able to understand a configuration file as a promise", async () => {
9 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.js"]);
10 |
11 | expect(exitCode).toBe(0);
12 | expect(stderr).toBeFalsy();
13 | expect(stdout).toBeTruthy();
14 | expect(existsSync(resolve(__dirname, "./binary/promise.js"))).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/test/serve/serve-variable/__snapshots__/serve-variable.test.js.snap.devServer5.webpack5:
--------------------------------------------------------------------------------
1 | // Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
2 |
3 | exports[`serve variable compiles without flags and export variable 1`] = `
4 | " [webpack-dev-server] Project is running at:
5 | [webpack-dev-server] Loopback: http://localhost:/, http://[::1]:/
6 | [webpack-dev-server] On Your Network (IPv4): http://x.x.x.x:/
7 | [webpack-dev-server] On Your Network (IPv6): http://[x:x:x:x:x:x:x:x]:/
8 | [webpack-dev-server] Content not from webpack is served from '/test/serve/serve-variable/public' directory"
9 | `;
10 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: npm
4 | directory: "/"
5 | schedule:
6 | interval: daily
7 | time: "04:00"
8 | timezone: Europe/Berlin
9 | open-pull-requests-limit: 20
10 | versioning-strategy: lockfile-only
11 | labels:
12 | - dependencies
13 | groups:
14 | dependencies:
15 | patterns:
16 | - "*"
17 | - package-ecosystem: "github-actions"
18 | directory: "/"
19 | schedule:
20 | interval: daily
21 | time: "04:00"
22 | timezone: Europe/Berlin
23 | open-pull-requests-limit: 20
24 | labels:
25 | - dependencies
26 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/loader/default/examples/simple/webpack.config.js.tpl:
--------------------------------------------------------------------------------
1 | const path = require('path');
2 |
3 | module.exports = {
4 | entry: './src/index.js',
5 | output: {
6 | path: path.join(__dirname, 'example_dist'),
7 | filename: '[name].chunk.js',
8 | },
9 | module: {
10 | rules: [
11 | {
12 | test: /\.js$/,
13 | use: [
14 | {
15 | loader: 'example-loader',
16 | options: {},
17 | },
18 | ],
19 | },
20 | ],
21 | },
22 | resolveLoader: {
23 | alias: {
24 | 'example-loader': require.resolve('../../src/'),
25 | },
26 | },
27 | };
28 |
--------------------------------------------------------------------------------
/test/build/config/defaults/dot-webpack-directory-webpackfile/dot-webpack-webpackfile.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe(".webpack webpackfile", () => {
8 | it("should build and not throw with .webpack webpackfile", async () => {
9 | const { stdout, stderr, exitCode } = await run(__dirname, []);
10 | expect(exitCode).toBe(0);
11 | expect(stderr).toBeFalsy();
12 | expect(stdout).toBeDefined();
13 | expect(existsSync(resolve(__dirname, "./binary/dev.folder.js"))).toBeTruthy();
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/test/build/config/defaults/dot-webpack-directory/dot-webpack-config.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe(".webpack configuration file", () => {
8 | it("should build and not throw error when config is present in .webpack", async () => {
9 | const { stdout, stderr, exitCode } = await run(__dirname, []);
10 | expect(exitCode).toBe(0);
11 | expect(stderr).toBeFalsy();
12 | expect(stdout).toBeDefined();
13 | expect(existsSync(resolve(__dirname, "./binary/dev.bundle.js"))).toBeTruthy();
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/test/serve/serve-variable/webpack.config.js:
--------------------------------------------------------------------------------
1 | const HAS_WEBPACK_SERVE = process.env.WEBPACK_SERVE || process.env.WEBPACK_DEV_SERVER;
2 |
3 | class CustomTestPlugin {
4 | constructor(isInEnvironment) {
5 | this.isInEnvironment = isInEnvironment;
6 | }
7 |
8 | apply(compiler) {
9 | compiler.hooks.done.tap("testPlugin", () => {
10 | if (this.isInEnvironment) {
11 | console.log("PASS");
12 | } else {
13 | console.log("FAIL");
14 | }
15 | });
16 | }
17 | }
18 |
19 | module.exports = (env) => ({
20 | mode: "development",
21 | devtool: false,
22 | plugins: [new CustomTestPlugin(HAS_WEBPACK_SERVE && env.WEBPACK_SERVE)],
23 | });
24 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/react/tsconfig.json.tpl:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "es5",
4 | "lib": ["dom", "dom.iterable", "esnext"],
5 | "allowJs": true,
6 | "skipLibCheck": true,
7 | "esModuleInterop": true,
8 | "allowSyntheticDefaultImports": true,
9 | "strict": true,
10 | "forceConsistentCasingInFileNames": true,
11 | "noFallthroughCasesInSwitch": true,
12 | "module": "esnext",
13 | "moduleResolution": "node",
14 | "resolveJsonModule": true,
15 | "isolatedModules": true,
16 | "jsx": "react-jsx"
17 | },
18 | "include": ["src/**/*", "index.d.ts"],
19 | "exclude": ["node_modules", "dist"]
20 | }
21 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/styles/global.less.tpl:
--------------------------------------------------------------------------------
1 | html,
2 | body {
3 | padding: 0;
4 | margin: 0;
5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
6 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
7 | }
8 |
9 | .heading {
10 | font-weight: 300;
11 | }
12 |
13 | .container {
14 | display: flex;
15 | align-items: center;
16 | justify-content: center;
17 | flex-direction: column;
18 | }
19 |
20 | #app {
21 | font-family: Helvetica, Arial, sans-serif;
22 | -webkit-font-smoothing: antialiased;
23 | text-align: center;
24 | color: #2c3e50;
25 | margin-top: 60px;
26 | }
27 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/styles/global.scss.tpl:
--------------------------------------------------------------------------------
1 | html,
2 | body {
3 | padding: 0;
4 | margin: 0;
5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
6 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
7 | }
8 |
9 | .heading {
10 | font-weight: 300;
11 | }
12 |
13 | .container {
14 | display: flex;
15 | align-items: center;
16 | justify-content: center;
17 | flex-direction: column;
18 | }
19 |
20 | #app {
21 | font-family: Helvetica, Arial, sans-serif;
22 | -webkit-font-smoothing: antialiased;
23 | text-align: center;
24 | color: #2c3e50;
25 | margin-top: 60px;
26 | }
27 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/styles/global.styl.tpl:
--------------------------------------------------------------------------------
1 | html,
2 | body {
3 | padding: 0;
4 | margin: 0;
5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
6 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
7 | }
8 |
9 | .heading {
10 | font-weight: 300;
11 | }
12 |
13 | .container {
14 | display: flex;
15 | align-items: center;
16 | justify-content: center;
17 | flex-direction: column;
18 | }
19 |
20 | #app {
21 | font-family: Helvetica, Arial, sans-serif;
22 | -webkit-font-smoothing: antialiased;
23 | text-align: center;
24 | color: #2c3e50;
25 | margin-top: 60px;
26 | }
27 |
--------------------------------------------------------------------------------
/test/build/config/type/promise-function/promise-function.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe("promise function", () => {
8 | it("is able to understand a configuration file as a promise", async () => {
9 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.js"]);
10 |
11 | expect(exitCode).toBe(0);
12 | expect(stderr).toBeFalsy();
13 | expect(stdout).toBeTruthy();
14 |
15 | expect(existsSync(resolve(__dirname, "./binary/promise.js"))).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/build/env/array/webpack.config.js:
--------------------------------------------------------------------------------
1 | const webpack = require("webpack");
2 |
3 | module.exports = [
4 | {
5 | output: {
6 | filename: "prod.js",
7 | },
8 | mode: "production",
9 | devtool: "eval-cheap-module-source-map",
10 | target: "node",
11 | plugins: [
12 | new webpack.DefinePlugin({
13 | PRODUCTION: JSON.stringify(true),
14 | }),
15 | ],
16 | },
17 | {
18 | output: {
19 | filename: "dev.js",
20 | },
21 | mode: "development",
22 | target: "node",
23 | plugins: [
24 | new webpack.DefinePlugin({
25 | PRODUCTION: JSON.stringify(false),
26 | }),
27 | ],
28 | },
29 | ];
30 |
--------------------------------------------------------------------------------
/test/utils/cli-plugin-test/plugin.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { cli } = require("webpack");
4 | const { run } = require("../test-utils");
5 |
6 | describe("webpack-cli-test-plugin Test", () => {
7 | it("should log the webpack configuration", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname);
9 |
10 | expect(exitCode).toBe(0);
11 | expect(stderr).toBeFalsy();
12 | expect(stdout).toContain("target: 'node'");
13 |
14 | if (typeof cli !== "undefined") {
15 | expect(stdout).toContain("alias: { alias: [ 'alias1', 'alias2' ] }");
16 | }
17 |
18 | expect(stdout).toContain("WebpackCLITestPlugin");
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/packages/info/src/index.ts:
--------------------------------------------------------------------------------
1 | import { type IWebpackCLI } from "webpack-cli";
2 |
3 | class InfoCommand {
4 | async apply(cli: IWebpackCLI): Promise {
5 | await cli.makeCommand(
6 | {
7 | name: "info",
8 | alias: "i",
9 | description: "Outputs information about your system.",
10 | usage: "[options]",
11 | pkg: "@webpack-cli/info",
12 | },
13 | cli.getInfoOptions(),
14 | async (options: { output: string; additionalPackage: string[] }) => {
15 | const info = await cli.getInfoOutput(options);
16 |
17 | cli.logger.raw(info);
18 | },
19 | );
20 | }
21 | }
22 |
23 | export default InfoCommand;
24 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/vue/src/store/index.js.tpl:
--------------------------------------------------------------------------------
1 | import { defineStore } from 'pinia'
2 |
3 | // Define your store
4 | export const useMainStore = defineStore('main', {
5 | state: () => {
6 | return {
7 | // Define your state here
8 | count: 0,
9 | user: null
10 | }
11 | },
12 | actions: {
13 | // Define your actions here
14 | increment() {
15 | this.count++
16 | },
17 | decrement() {
18 | this.count--
19 | },
20 | setUser(user) {
21 | this.user = user
22 | }
23 | },
24 | getters: {
25 | // Define your getters here (optional)
26 | isLoggedIn: (state) => !!state.user,
27 | }
28 | })
29 |
--------------------------------------------------------------------------------
/test/build/config/defaults/with-mode/default-config-with-mode.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe("default config with mode from cli", () => {
8 | it("should build and not throw error with development mode supplied", async () => {
9 | const { stdout, stderr, exitCode } = await run(__dirname, ["--mode", "development"]);
10 | expect(exitCode).toBe(0);
11 | expect(stderr).toBeFalsy();
12 | expect(stdout).toBeDefined();
13 | expect(existsSync(resolve(__dirname, "./binary/dev.bundle.js"))).toBeTruthy();
14 | });
15 | });
16 |
--------------------------------------------------------------------------------
/test/build/config/invalid-export/invalid-export.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config with invalid export", () => {
7 | it("should throw error with configuration exporting invalid configuration", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(2);
14 | expect(stderr).toContain(
15 | `Invalid configuration in '${resolve(__dirname, "webpack.config.js")}'`,
16 | );
17 | expect(stdout).toBeFalsy();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/test/build/entry/config-entry/entry-with-config/entry-with-config.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe("default entry and config entry all exist", () => {
8 | it("should use config entry if config entry existed", async () => {
9 | const { stdout, stderr, exitCode } = await run(__dirname, ["-c", "../1.js"]);
10 |
11 | expect(exitCode).toBe(0);
12 | expect(stderr).toBeFalsy();
13 | expect(stdout).toContain("./a.js");
14 | expect(existsSync(resolve(__dirname, "./binary/index.bundle.js"))).toBeTruthy();
15 | });
16 | });
17 |
--------------------------------------------------------------------------------
/test/build/config-format/coffee/coffee.test.js:
--------------------------------------------------------------------------------
1 | const { run } = require("../../../utils/test-utils");
2 |
3 | describe("webpack cli", () => {
4 | it("should support coffeescript file as flag", async () => {
5 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "webpack.config.coffee"]);
6 |
7 | expect(exitCode).toBe(0);
8 | expect(stderr).toBeFalsy();
9 | expect(stdout).toBeTruthy();
10 | });
11 |
12 | it("should load coffeescript file by default", async () => {
13 | const { exitCode, stderr, stdout } = await run(__dirname, []);
14 |
15 | expect(exitCode).toBe(0);
16 | expect(stderr).toBeFalsy();
17 | expect(stdout).toBeTruthy();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/test/build/config/type/function/function.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe("function", () => {
8 | it("is able to understand a configuration file as a function", async () => {
9 | const { exitCode, stderr, stdout } = await run(__dirname, [
10 | "-c",
11 | resolve(__dirname, "webpack.config.js"),
12 | ]);
13 |
14 | expect(exitCode).toBe(0);
15 | expect(stderr).toBeFalsy();
16 | expect(stdout).toBeTruthy();
17 | expect(existsSync(resolve(__dirname, "./binary/functor.js"))).toBeTruthy();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/styles/global.css.tpl:
--------------------------------------------------------------------------------
1 | html,
2 | body {
3 | padding: 0;
4 | margin: 0;
5 | font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
6 | Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
7 | }
8 |
9 | .heading {
10 | font-weight: 300;
11 | bg-color: #f0f0f0;
12 | }
13 |
14 | .container {
15 | display: flex;
16 | align-items: center;
17 | justify-content: center;
18 | flex-direction: column;
19 | }
20 |
21 | #app {
22 | font-family: Helvetica, Arial, sans-serif;
23 | -webkit-font-smoothing: antialiased;
24 | text-align: center;
25 | color: #2c3e50;
26 | margin-top: 60px;
27 | }
28 |
--------------------------------------------------------------------------------
/test/build/entry/scss/webpack.config.js:
--------------------------------------------------------------------------------
1 | const MiniCssExtractPlugin = require("mini-css-extract-plugin");
2 |
3 | module.exports = {
4 | mode: "development",
5 | entry: {
6 | home: ["./home.js", "./home.scss"],
7 | },
8 | output: {
9 | filename: "[name].js",
10 | },
11 | module: {
12 | rules: [
13 | {
14 | test: /\.scss$/,
15 | use: [
16 | // fallback to style-loader in development
17 | MiniCssExtractPlugin.loader,
18 | "css-loader",
19 | "sass-loader",
20 | ],
21 | },
22 | ],
23 | },
24 | plugins: [
25 | new MiniCssExtractPlugin({
26 | filename: "[name].css",
27 | }),
28 | ],
29 | };
30 |
--------------------------------------------------------------------------------
/packages/configtest/README.md:
--------------------------------------------------------------------------------
1 | # webpack-cli configtest
2 |
3 | [![NPM Downloads][downloads]][downloads-url]
4 |
5 | > **Note**
6 | >
7 | > This package is used by webpack-cli under-the-hood and is not intended for installation
8 |
9 | ## Description
10 |
11 | This package validates a webpack configuration.
12 |
13 | ## Installation
14 |
15 | ```bash
16 | # npm
17 | npm i -D @webpack-cli/configtest
18 |
19 | # yarn
20 | yarn add -D @webpack-cli/configtest
21 |
22 | ```
23 |
24 | ## Usage
25 |
26 | ```bash
27 | npx webpack configtest [config-path]
28 | ```
29 |
30 | [downloads]: https://img.shields.io/npm/dm/@webpack-cli/configtest.svg
31 | [downloads-url]: https://www.npmjs.com/package/@webpack-cli/configtest
32 |
--------------------------------------------------------------------------------
/packages/configtest/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@webpack-cli/configtest",
3 | "version": "3.0.1",
4 | "description": "Validate a webpack configuration.",
5 | "homepage": "https://github.com/webpack/webpack-cli/tree/main/packages/configtest",
6 | "repository": {
7 | "type": "git",
8 | "url": "https://github.com/webpack/webpack-cli.git"
9 | },
10 | "license": "MIT",
11 | "main": "lib/index.js",
12 | "types": "lib/index.d.ts",
13 | "files": [
14 | "lib"
15 | ],
16 | "peerDependencies": {
17 | "webpack": "^5.82.0",
18 | "webpack-cli": "6.x.x"
19 | },
20 | "engines": {
21 | "node": ">=18.12.0"
22 | },
23 | "publishConfig": {
24 | "access": "public"
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/test/build/config-lookup/dotfolder-single/dotfolder-single.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 |
6 | const { run } = require("../../../utils/test-utils");
7 |
8 | describe("dotfolder single config lookup", () => {
9 | it("should find a webpack configuration in a dotfolder", async () => {
10 | const { exitCode, stderr, stdout } = await run(__dirname, []);
11 |
12 | expect(exitCode).toBe(0);
13 | expect(stderr).toBeFalsy();
14 | expect(stdout).not.toContain("Module not found");
15 | expect(stdout).toBeTruthy();
16 | expect(existsSync(resolve(__dirname, "./dist/main.js"))).toBeTruthy();
17 | });
18 | });
19 |
--------------------------------------------------------------------------------
/test/build/config/multiple-with-one-compilation/multiple-with-one-compilation.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { resolve } = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config with single config in array", () => {
7 | it("should build and not throw error with configuration file exporting single configuration in array", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | resolve(__dirname, "webpack.config.js"),
11 | "--output-path",
12 | "./binary",
13 | ]);
14 | expect(exitCode).toBe(0);
15 | expect(stderr).toBeFalsy();
16 | expect(stdout).toBeTruthy();
17 | });
18 | });
19 |
--------------------------------------------------------------------------------
/test/build/config/invalid-path/invalid-path.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const path = require("node:path");
4 | const { run } = require("../../../utils/test-utils");
5 |
6 | describe("config with invalid path supplied by CLI", () => {
7 | it("should throw error when invalid configuration path is passed to cli", async () => {
8 | const { exitCode, stderr, stdout } = await run(__dirname, [
9 | "-c",
10 | path.resolve(__dirname, "invalid-webpack.config.js"),
11 | ]);
12 |
13 | expect(exitCode).toBe(2);
14 | expect(stderr).toContain(
15 | `Failed to load '${path.resolve(__dirname, "invalid-webpack.config.js")}' config`,
16 | );
17 | expect(stdout).toBeFalsy();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/test/build/config/type/function-async/function-async.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe("function async", () => {
8 | it("is able to understand a configuration file as a function", async () => {
9 | const { exitCode, stderr, stdout } = await run(__dirname, [
10 | "-c",
11 | resolve(__dirname, "webpack.config.js"),
12 | ]);
13 |
14 | expect(exitCode).toBe(0);
15 | expect(stderr).toBeFalsy();
16 | expect(stdout).toBeTruthy();
17 | expect(existsSync(resolve(__dirname, "./binary/functor.js"))).toBeTruthy();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/test/build/import-local/import-local.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { run } = require("../../utils/test-utils");
4 |
5 | const importLocalMock = jest.fn();
6 | jest.setMock("import-local", importLocalMock);
7 |
8 | describe("import local", () => {
9 | beforeEach(() => {
10 | importLocalMock.mockClear();
11 | });
12 |
13 | it("should skip import local when supplied", async () => {
14 | const { exitCode, stderr, stdout } = await run(__dirname, [], {
15 | env: { WEBPACK_CLI_SKIP_IMPORT_LOCAL: true },
16 | });
17 | expect(importLocalMock).not.toHaveBeenCalled();
18 | expect(exitCode).toBe(0);
19 | expect(stderr).toBeFalsy();
20 | expect(stdout).toBeTruthy();
21 | });
22 | });
23 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/main.js.tpl:
--------------------------------------------------------------------------------
1 | import App from './App.svelte';
2 |
3 | <% if (cssType == 'CSS only') { %>
4 | import "./styles/global.css";<% } if (cssType == 'SASS') { %>
5 | import "./styles/global.scss";<% } if (cssType == 'LESS') { %>
6 | import "./styles/global.less";<% } if (cssType == 'Stylus') { %>
7 | import "./styles/global.styl";<% } %>
8 |
9 |
10 | const app = new App({
11 | target: document.getElementById('app'),
12 | });
13 |
14 | export default app;
15 |
16 | <% if (workboxWebpackPlugin) { %>
17 | if ('serviceWorker' in navigator) {
18 | window.addEventListener('load', () => {
19 | navigator.serviceWorker.register('/service-worker.js');
20 | });
21 | }
22 | <% } %>
23 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/main.ts.tpl:
--------------------------------------------------------------------------------
1 | import App from './App.svelte';
2 |
3 | <% if (cssType == 'CSS only') { %>
4 | import "./styles/global.css";<% } if (cssType == 'SASS') { %>
5 | import "./styles/global.scss";<% } if (cssType == 'LESS') { %>
6 | import "./styles/global.less";<% } if (cssType == 'Stylus') { %>
7 | import "./styles/global.styl";<% } %>
8 |
9 |
10 | const app = new App({
11 | target: document.getElementById('app'),
12 | });
13 |
14 | export default app;
15 |
16 | <% if (workboxWebpackPlugin) { %>
17 | if ('serviceWorker' in navigator) {
18 | window.addEventListener('load', () => {
19 | navigator.serviceWorker.register('/service-worker.js');
20 | });
21 | }
22 | <% } %>
23 |
--------------------------------------------------------------------------------
/test/build/config/type/function-promise/function-promise.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe("function promise", () => {
8 | it("is able to understand a configuration file as a function", async () => {
9 | const { exitCode, stderr, stdout } = await run(__dirname, [
10 | "-c",
11 | resolve(__dirname, "webpack.config.js"),
12 | ]);
13 |
14 | expect(exitCode).toBe(0);
15 | expect(stderr).toBeFalsy();
16 | expect(stdout).toBeTruthy();
17 | expect(existsSync(resolve(__dirname, "./binary/functor.js"))).toBeTruthy();
18 | });
19 | });
20 |
--------------------------------------------------------------------------------
/test/serve/basic/multi.config.js:
--------------------------------------------------------------------------------
1 | const WebpackCLITestPlugin = require("../../utils/webpack-cli-test-plugin");
2 | const { devServerConfig } = require("./helper/base-dev-server.config");
3 |
4 | module.exports = [
5 | {
6 | name: "one",
7 | mode: "development",
8 | devtool: false,
9 | output: {
10 | filename: "first-output/[name].js",
11 | },
12 | devServer: devServerConfig,
13 | plugins: [new WebpackCLITestPlugin(["mode", "output"], false, "hooks.compilation.taps")],
14 | },
15 | {
16 | name: "two",
17 | mode: "development",
18 | devtool: false,
19 | entry: "./src/other.js",
20 | output: {
21 | filename: "second-output/[name].js",
22 | },
23 | },
24 | ];
25 |
--------------------------------------------------------------------------------
/packages/create-webpack-app/templates/init/svelte/src/components/HelloWorld.svelte.tpl:
--------------------------------------------------------------------------------
1 |
24 |
25 |
26 |
27 | {reactiveMsg}
28 |
29 |
30 | This is a Webpack + Svelte project.
31 |
32 |
33 |
--------------------------------------------------------------------------------
/test/build/config-lookup/dotfolder-array/dotfolder-array.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../utils/test-utils");
6 |
7 | describe("dotfolder array config lookup", () => {
8 | it("should find a webpack array configuration in a dotfolder", async () => {
9 | const { exitCode, stderr, stdout } = await run(__dirname, []);
10 |
11 | expect(exitCode).toBe(0);
12 | expect(stderr).toBeFalsy();
13 | expect(stdout).toBeTruthy();
14 | expect(existsSync(resolve(__dirname, "./dist/dist-commonjs.js"))).toBeTruthy();
15 | expect(existsSync(resolve(__dirname, "./dist/dist-amd.js"))).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------
/test/build/config/multiple/multiple-config.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { run } = require("../../../utils/test-utils");
4 |
5 | describe("multiple configuration files", () => {
6 | it("should not throw error and spawn compilers for each configuration file", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, [
8 | "--config",
9 | "webpack1.config.js",
10 | "--config",
11 | "webpack2.config.js",
12 | ]);
13 |
14 | // Should contain the correct exit code
15 | expect(exitCode).toBe(0);
16 | expect(stderr).toBeFalsy();
17 | // Should spawn multiple compilers
18 | expect(stdout).toContain("amd:");
19 | expect(stdout).toContain("commonjs:");
20 | });
21 | });
22 |
--------------------------------------------------------------------------------
/test/build/config/type/array-promises/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("node:path");
2 |
3 | module.exports = [
4 | new Promise((resolve) => {
5 | setTimeout(() => {
6 | resolve({
7 | entry: "./a",
8 | name: "first",
9 | output: {
10 | path: path.resolve(__dirname, "./binary"),
11 | filename: "a-promise.js",
12 | },
13 | });
14 | }, 0);
15 | }),
16 | new Promise((resolve) => {
17 | setTimeout(() => {
18 | resolve({
19 | entry: "./b",
20 | name: "second",
21 | output: {
22 | path: path.resolve(__dirname, "./binary"),
23 | filename: "b-promise.js",
24 | },
25 | });
26 | }, 0);
27 | }),
28 | ];
29 |
--------------------------------------------------------------------------------
/test/build/analyze/analyze-flag.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { normalizeStdout, run } = require("../../utils/test-utils");
4 |
5 | describe('"analyze" option', () => {
6 | it("should not load webpack-bundle-analyzer plugin twice with --analyze flag and plugin", async () => {
7 | const { exitCode, stderr, stdout } = await run(__dirname, [
8 | "-c",
9 | "./analyze.config.js",
10 | "--analyze",
11 | ]);
12 |
13 | expect(exitCode).toBe(0);
14 | expect(stderr).toBeFalsy();
15 | expect(normalizeStdout(stdout)).toContain("Webpack Bundle Analyzer saved report to");
16 | expect(normalizeStdout(stdout).match(/Webpack Bundle Analyzer saved report to/g)).toHaveLength(
17 | 1,
18 | );
19 | });
20 | });
21 |
--------------------------------------------------------------------------------
/test/build/config/type/promise-array/promise-array.test.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | const { existsSync } = require("node:fs");
4 | const { resolve } = require("node:path");
5 | const { run } = require("../../../../utils/test-utils");
6 |
7 | describe("promise array", () => {
8 | it("is able to understand a configuration file as a promise", async () => {
9 | const { exitCode, stderr, stdout } = await run(__dirname, ["-c", "./webpack.config.js"]);
10 |
11 | expect(exitCode).toBe(0);
12 | expect(stdout).toBeTruthy();
13 | expect(stderr).toBeFalsy();
14 | expect(existsSync(resolve(__dirname, "./binary/a-promise.js"))).toBeTruthy();
15 | expect(existsSync(resolve(__dirname, "./binary/a-promise.js"))).toBeTruthy();
16 | });
17 | });
18 |
--------------------------------------------------------------------------------