├── .nvmrc ├── .github ├── funding.yml ├── ISSUE_TEMPLATE │ ├── SUPPORT.md │ ├── FEATURE.md │ ├── MODIFICATION.md │ ├── DOCS.md │ └── BUG.md ├── ISSUE_TEMPLATE.md ├── CONTRIBUTING.md ├── PULL_REQUEST_TEMPLATE.md └── labels.json ├── test ├── fixtures │ ├── multi │ │ ├── component.js │ │ ├── work.js │ │ ├── index.html │ │ ├── worker.js │ │ ├── app.js │ │ └── webpack.config.js │ └── simple │ │ ├── component.js │ │ ├── package.json │ │ ├── index.html │ │ ├── webpack.config.js │ │ └── app.js ├── snapshots │ ├── multi.test.js.snap │ ├── single.test.js.snap │ ├── single.test.js.md │ └── multi.test.js.md ├── multi.test.js ├── single.test.js └── helpers │ └── setup.js ├── .eslintignore ├── .eslintrc ├── codecov.yml ├── .gitignore ├── .editorconfig ├── .circleci ├── setup-puppeteer.sh └── config.yml ├── commitlint.config.js ├── lib ├── compiler.js ├── flags.js ├── plugin.js └── config.js ├── package.json ├── bin └── webpack-serve ├── assets └── serve.svg ├── README.md └── LICENSE /.nvmrc: -------------------------------------------------------------------------------- 1 | 10 2 | -------------------------------------------------------------------------------- /.github/funding.yml: -------------------------------------------------------------------------------- 1 | patreon: shellscape 2 | custom: https://paypal.me/shellscape 3 | liberapay: shellscape 4 | -------------------------------------------------------------------------------- /test/fixtures/multi/component.js: -------------------------------------------------------------------------------- 1 | const main = document.querySelector('main'); 2 | main.innerHTML = 'main'; 3 | -------------------------------------------------------------------------------- /test/fixtures/simple/component.js: -------------------------------------------------------------------------------- 1 | const main = document.querySelector('main'); 2 | main.innerHTML = 'main'; 3 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | dist 3 | *.snap 4 | output.js 5 | *-wps-hmr.* 6 | *.hot-update.js 7 | test/**/output 8 | -------------------------------------------------------------------------------- /test/snapshots/multi.test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shellscape/webpack-serve/HEAD/test/snapshots/multi.test.js.snap -------------------------------------------------------------------------------- /test/snapshots/single.test.js.snap: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shellscape/webpack-serve/HEAD/test/snapshots/single.test.js.snap -------------------------------------------------------------------------------- /test/fixtures/multi/work.js: -------------------------------------------------------------------------------- 1 | const worker = document.querySelector('#worker'); 2 | worker.innerHTML = 'worker'; 3 | 4 | // console.log(require); 5 | -------------------------------------------------------------------------------- /test/fixtures/simple/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "some-package", 3 | "version": "1.0.0", 4 | "serve": { 5 | "port": 50000 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "shellscape", 3 | "globals": { 4 | "document": true, 5 | "WebSocket": true, 6 | "window": true 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | branch: master 3 | coverage: 4 | precision: 2 5 | round: down 6 | range: 70...100 7 | status: 8 | project: 'no' 9 | patch: 'yes' 10 | comment: 'off' 11 | -------------------------------------------------------------------------------- /test/fixtures/simple/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | fixture: single 5 | 6 | 7 |
8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | npm-debug.log 3 | coverage 4 | node_modules 5 | .eslintcache 6 | .idea 7 | 8 | test/**/output* 9 | output.js 10 | output.js.map 11 | *.hot-update.* 12 | wps-hmr.* 13 | 14 | .nyc_output 15 | coverage.lcov 16 | 17 | dist 18 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.md] 13 | insert_final_newline = true 14 | trim_trailing_whitespace = false -------------------------------------------------------------------------------- /test/fixtures/multi/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | fixture: multicompiler 5 | 6 | 7 |
8 |
9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /test/fixtures/simple/webpack.config.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require('path'); 2 | 3 | module.exports = { 4 | context: __dirname, 5 | entry: ['./app.js'], 6 | mode: 'development', 7 | output: { 8 | filename: './output.js', 9 | path: resolve(__dirname, './output'), 10 | publicPath: 'output/' 11 | } 12 | }; 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/SUPPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🆘 Support, Help, and Advice 3 | about: 👉🏽 If you want to ask how to do a thing with this project, this is the place for you. 4 | 5 | --- 6 | 7 | If you arrived here because you think this project's documentation is unclear, insufficient, or wrong, please consider creating an issue for the documentation instead. 8 | -------------------------------------------------------------------------------- /test/fixtures/multi/worker.js: -------------------------------------------------------------------------------- 1 | require('./work'); 2 | 3 | const { error } = console; 4 | 5 | if (module.hot) { 6 | module.hot.accept((err) => { 7 | if (err) { 8 | error('HMR', err); 9 | } 10 | }); 11 | } 12 | 13 | // uncomment to produce a build error 14 | // if (!window) { 15 | // require('tests'); 16 | // } 17 | 18 | // uncomment to produce a build warning 19 | // console.log(require); 20 | -------------------------------------------------------------------------------- /test/fixtures/multi/app.js: -------------------------------------------------------------------------------- 1 | require('./component'); 2 | 3 | const { error } = console; 4 | 5 | if (module.hot) { 6 | module.hot.accept((err) => { 7 | if (err) { 8 | error('HMR', err); 9 | } 10 | }); 11 | } 12 | 13 | // uncomment to produce a build error 14 | // if (!window) { 15 | // require('tests'); 16 | // } 17 | 18 | // uncomment to produce a build warning 19 | // console.log(require); 20 | -------------------------------------------------------------------------------- /test/multi.test.js: -------------------------------------------------------------------------------- 1 | const test = require('ava'); 2 | 3 | const { setup } = require('./helpers/setup'); 4 | 5 | test('multi compiler', setup('multi'), async (t, util) => { 6 | const { page, run, url } = util; 7 | 8 | await run('--all'); 9 | await page.goto(url, { 10 | waitUntil: 'networkidle0' 11 | }); 12 | 13 | const html = await page.evaluate(() => document.body.innerHTML); 14 | 15 | t.snapshot(html); 16 | }); 17 | -------------------------------------------------------------------------------- /test/fixtures/simple/app.js: -------------------------------------------------------------------------------- 1 | require('./component'); 2 | 3 | const { error } = console; 4 | 5 | if (module.hot) { 6 | module.hot.accept((err) => { 7 | if (err) { 8 | error('HMR', err); 9 | } 10 | }); 11 | } 12 | 13 | // uncomment to produce a build error 14 | // if (!window) { 15 | // require('tests'); 16 | // } 17 | 18 | // uncomment to produce a build warning 19 | // console.log(require); 20 | 21 | // console.log(require); 22 | -------------------------------------------------------------------------------- /test/single.test.js: -------------------------------------------------------------------------------- 1 | const test = require('ava'); 2 | 3 | const { setup } = require('./helpers/setup'); 4 | 5 | test('single compiler', setup('simple', false), async (t, util) => { 6 | const { page, run } = util; 7 | 8 | await run(); 9 | await page.goto('http://localhost:50000', { 10 | waitUntil: 'networkidle0' 11 | }); 12 | 13 | const html = await page.evaluate(() => document.body.innerHTML); 14 | 15 | t.snapshot(html); 16 | }); 17 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: ✨ Feature Request 3 | about: Suggest an idea for this project 4 | 5 | --- 6 | 7 | 16 | 17 | ### Feature Use Case 18 | 19 | 20 | ### Feature Proposal 21 | -------------------------------------------------------------------------------- /.circleci/setup-puppeteer.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | sudo apt-get update 4 | sudo apt-get install -yq gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \ 5 | libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \ 6 | libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \ 7 | libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \ 8 | ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget 9 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 14 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/MODIFICATION.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🔧 Modification Request 3 | about: Would you like something work differently? Have an alternative approach? This is the template for you. 4 | 5 | --- 6 | 7 | 16 | 17 | 18 | ### Expected Behavior / Situation 19 | 20 | 21 | ### Actual Behavior / Situation 22 | 23 | 24 | ### Modification Proposal 25 | -------------------------------------------------------------------------------- /test/fixtures/multi/webpack.config.js: -------------------------------------------------------------------------------- 1 | const { resolve } = require('path'); 2 | 3 | module.exports = [ 4 | { 5 | context: __dirname, 6 | entry: './app.js', 7 | mode: 'development', 8 | output: { 9 | filename: './dist-app.js', 10 | path: resolve(__dirname, './output'), 11 | publicPath: 'output/' 12 | } 13 | }, 14 | { 15 | context: __dirname, 16 | entry: ['./worker.js'], 17 | mode: 'development', 18 | output: { 19 | filename: './dist-worker.js', 20 | path: resolve(__dirname, './output'), 21 | publicPath: 'output/' 22 | } 23 | } 24 | ]; 25 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Contributing in webpack-serve 2 | 3 | We 💛 contributions! The rules for contributing to this org are few: 4 | 5 | 1. Don't be a jerk 6 | 1. Search issues before opening a new one 7 | 1. Lint and run tests locally before submitting a PR 8 | 1. Adhere to the code style the org has chosen 9 | 10 | 11 | ## Before Committing 12 | 13 | 1. Use at least Node.js v10.11.0 or higher. [NVM](https://github.com/creationix/nvm) can be handy for switching between Node versions. 14 | 1. Lint your changes via `npm run lint`. Fix any errors and warnings before committing. 15 | 1. Test your changes via `npm run test`. Only Pull Requests with passing tests will be accepted. 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/DOCS.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 📚 Documentation 3 | about: Are the docs lacking or missing something? Do they need some new 🔥 hotness? Tell us here. 4 | 5 | --- 6 | 7 | 16 | 17 | Documentation Is: 18 | 19 | 20 | 21 | - [ ] Missing 22 | - [ ] Needed 23 | - [ ] Confusing 24 | - [ ] Not Sure? 25 | 26 | ### Please Explain in Detail... 27 | 28 | 29 | ### Your Proposal for Changes 30 | -------------------------------------------------------------------------------- /commitlint.config.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | const Configuration = { 3 | extends: ['@commitlint/config-conventional'], 4 | 5 | rules: { 6 | 'body-leading-blank': [1, 'always'], 7 | 'footer-leading-blank': [1, 'always'], 8 | 'header-max-length': [2, 'always', 72], 9 | 'scope-case': [2, 'always', 'lower-case'], 10 | 'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']], 11 | 'subject-empty': [2, 'never'], 12 | 'subject-full-stop': [2, 'never', '.'], 13 | 'type-case': [2, 'always', 'lower-case'], 14 | 'type-empty': [2, 'never'], 15 | 'type-enum': [2, 'always', [ 16 | 'build', 17 | 'chore', 18 | 'ci', 19 | 'docs', 20 | 'feat', 21 | 'fix', 22 | 'perf', 23 | 'refactor', 24 | 'revert', 25 | 'style', 26 | 'test', 27 | ], 28 | ], 29 | }, 30 | }; 31 | 32 | module.exports = Configuration; -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 14 | 15 | This PR contains: 16 | 17 | - [ ] bugfix 18 | - [ ] feature 19 | - [ ] refactor 20 | - [ ] tests 21 | - [ ] documentation 22 | - [ ] metadata 23 | 24 | ### Breaking Changes? 25 | 26 | - [ ] yes 27 | - [ ] no 28 | 29 | If yes, please describe the breakage. 30 | 31 | ### Please Describe Your Changes 32 | 33 | 38 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐞 Bug Report 3 | about: Something went awry and you'd like to tell us about it. 4 | 5 | --- 6 | 7 | 16 | 17 | - Webpack Version: 18 | - Operating System (or Browser): 19 | - Node Version: 20 | - webpack-serve Version: 21 | 22 | ### How Do We Reproduce? 23 | 24 | 29 | 30 | 31 | ### Expected Behavior 32 | 33 | 34 | ### Actual Behavior 35 | 36 | 39 | -------------------------------------------------------------------------------- /test/snapshots/single.test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/single.test.js` 2 | 3 | The actual snapshot is saved in `single.test.js.snap`. 4 | 5 | Generated by [AVA](https://ava.li). 6 | 7 | ## single compiler 8 | 9 | > Snapshot 1 10 | 11 | `␊ 12 |
main
␊ 13 | ␊ 14 | ␊ 15 | ␊ 16 | ␊ 17 | ␊ 18 | ␊ 19 | 0%␊ 20 | ` 39 | -------------------------------------------------------------------------------- /test/helpers/setup.js: -------------------------------------------------------------------------------- 1 | const { join } = require('path'); 2 | 3 | const execa = require('execa'); 4 | const getPort = require('get-port'); 5 | const puppeteer = require('puppeteer'); 6 | const strip = require('strip-ansi'); 7 | 8 | const binPath = join(__dirname, '../../bin/webpack-serve'); 9 | 10 | const waitForBuild = (stderr) => { 11 | return { 12 | then(r) { 13 | stderr.on('data', (data) => { 14 | const content = strip(data.toString()); 15 | if (/webpack: Hash:/.test(content)) { 16 | r(); 17 | } 18 | }); 19 | } 20 | }; 21 | }; 22 | 23 | const setup = (fixture, randomPort = true) => async (t, run) => { 24 | const instance = await puppeteer.launch({ args: ['--no-sandbox', '--disable-setuid-sandbox'] }); 25 | const page = await instance.newPage(); 26 | const fixturePath = join(__dirname, '../fixtures', fixture); 27 | let url = ''; 28 | 29 | const args = [binPath]; 30 | 31 | if (randomPort) { 32 | const port = await getPort({ port: Math.floor(Math.random() * (55600 - 55555) + 55555) }); 33 | args.push(`--port=${port}`); 34 | url = `http://localhost:${port}`; 35 | } 36 | 37 | const util = { 38 | page, 39 | run: (...flags) => { 40 | const { stderr } = execa('node', args.concat(flags), { 41 | cwd: fixturePath 42 | }); 43 | // stderr.on('data', (d) => console.log(d.toString())); 44 | return waitForBuild(stderr); 45 | }, 46 | url 47 | }; 48 | try { 49 | await run(t, util); 50 | } finally { 51 | await page.close(); 52 | await instance.close(); 53 | } 54 | }; 55 | 56 | module.exports = { setup }; 57 | -------------------------------------------------------------------------------- /test/snapshots/multi.test.js.md: -------------------------------------------------------------------------------- 1 | # Snapshot report for `test/multi.test.js` 2 | 3 | The actual snapshot is saved in `multi.test.js.snap`. 4 | 5 | Generated by [AVA](https://ava.li). 6 | 7 | ## multi compiler 8 | 9 | > Snapshot 1 10 | 11 | `␊ 12 |
main
␊ 13 |
worker
␊ 14 | ␊ 15 | ␊ 16 | ␊ 17 | ␊ 18 | ␊ 19 | ␊ 20 | ␊ 21 | 0%␊ 22 | ` 41 | -------------------------------------------------------------------------------- /lib/compiler.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2018 Andrew Powell 3 | 4 | This Source Code Form is subject to the terms of the Mozilla Public 5 | License, v. 2.0. If a copy of the MPL was not distributed with this 6 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | The above copyright notice and this permission notice shall be 9 | included in all copies or substantial portions of this Source Code Form. 10 | */ 11 | const chalk = require('chalk'); 12 | const webpack = require('webpack'); 13 | 14 | const run = ({ config, watchConfig }, log) => { 15 | let lastHash; 16 | const compiler = webpack(config); 17 | 18 | const done = (fatal, stats) => { 19 | const hasErrors = stats && stats.hasErrors(); 20 | 21 | process.exitCode = Number(!!fatal || (hasErrors && !watchConfig)); 22 | 23 | if (fatal) { 24 | log.error(fatal); 25 | return; 26 | } 27 | 28 | if (lastHash === stats.hash) { 29 | log.info(chalk`{dim ˢᵉʳᵛᵉ} Duplicate build detected {dim (${lastHash})}\n`); 30 | return; 31 | } 32 | 33 | lastHash = stats.hash; 34 | 35 | const statsDefaults = { colors: chalk.supportsColor.hasBasic, exclude: ['node_modules'] }; 36 | const { options = {} } = 37 | [] 38 | .concat(compiler.compilers || compiler) 39 | .reduce((a, c) => c.options.stats && c.options.stats) || {}; 40 | const statsOptions = 41 | !options.stats || typeof options.stats === 'object' 42 | ? Object.assign({}, statsDefaults, options.stats) 43 | : options.stats; 44 | const result = stats.toString(statsOptions); 45 | 46 | // indent the result slightly to visually set it apart from other output 47 | log.info(result.split('\n').join('\n '), '\n'); 48 | }; 49 | 50 | if (watchConfig) { 51 | log.info('Watching Files'); 52 | compiler.watch(watchConfig.watchOptions || {}, done); 53 | } else { 54 | compiler.hooks.done.tap('webpack-serve', () => log.info('Build Finished')); 55 | compiler.run(done); 56 | } 57 | }; 58 | 59 | module.exports = { run }; 60 | -------------------------------------------------------------------------------- /lib/flags.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2018 Andrew Powell 3 | 4 | This Source Code Form is subject to the terms of the Mozilla Public 5 | License, v. 2.0. If a copy of the MPL was not distributed with this 6 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | The above copyright notice and this permission notice shall be 9 | included in all copies or substantial portions of this Source Code Form. 10 | */ 11 | const chalk = require('chalk'); 12 | const decamelize = require('decamelize'); 13 | const objectPath = require('object-path'); 14 | 15 | const custom = ['clientAddress', 'clientRetry', 'clientSilent']; 16 | const allowed = ['_', 'all', 'config', 'help', 'silent', 'version']; 17 | const plugin = [ 18 | 'compress', 19 | 'historyFallback', 20 | 'hmr', 21 | 'host', 22 | 'http2', 23 | 'liveReload', 24 | 'open', 25 | 'port', 26 | 'progress', 27 | 'static', 28 | 'status', 29 | 'waitForBuild' 30 | ]; 31 | 32 | module.exports = { 33 | check(flags) { 34 | const validFlags = [].concat(allowed, custom, plugin); 35 | // eslint-disable-next-line no-bitwise 36 | const userFlags = Object.keys(flags).filter((flag) => flag.indexOf('-') === -1); 37 | const deprecated = userFlags 38 | .filter((flag) => !validFlags.includes(flag)) 39 | .map((flag) => decamelize(flag, '-')); 40 | 41 | if (deprecated.length) { 42 | const { error: stderr } = console; 43 | 44 | stderr(chalk`{yellow ˢᵉʳᵛᵉ} Some options were passed which are unsupported: 45 | 46 | {blue --${deprecated.join('\n --')}} 47 | 48 | {dim Please run {reset webpack-serve --help} for a list of supported flags.} 49 | `); 50 | } 51 | }, 52 | 53 | prepare(flags) { 54 | const result = {}; 55 | 56 | for (const flag of Object.keys(flags)) { 57 | const value = flags[flag]; 58 | if (plugin.includes(flag)) { 59 | result[flag] = value; 60 | } 61 | 62 | if (custom.includes(flag)) { 63 | const path = decamelize(flag, '.'); 64 | objectPath.set(result, path, value); 65 | } 66 | } 67 | 68 | return result; 69 | } 70 | }; 71 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | jobs: 3 | dependency_cache: 4 | docker: 5 | - image: rollupcabal/circleci-node-base:latest 6 | steps: 7 | - checkout 8 | - restore_cache: 9 | key: dependency-cache-{{ checksum "package-lock.json" }} 10 | - run: 11 | name: Node Info 12 | command: node --version && npm --version 13 | - run: 14 | name: Install Dependencies 15 | command: npm install 16 | - save_cache: 17 | key: dependency-cache-{{ checksum "package-lock.json" }} 18 | paths: 19 | - ./node_modules 20 | node-v10-latest: 21 | docker: 22 | - image: rollupcabal/circleci-node-v10:latest 23 | steps: 24 | - checkout 25 | - restore_cache: 26 | key: dependency-cache-{{ checksum "package-lock.json" }} 27 | - run: 28 | name: Node Info 29 | command: node --version && npm --version 30 | - run: 31 | name: Workaround for GoogleChrome/puppeteer#290 32 | command: 'sh .circleci/setup-puppeteer.sh' 33 | - run: 34 | name: NPM Rebuild 35 | command: npm install 36 | - run: 37 | name: Run unit tests. 38 | command: npm run ci:coverage 39 | - run: 40 | name: Submit coverage data to codecov. 41 | command: bash <(curl -s https://codecov.io/bash) 42 | when: on_success 43 | analysis: 44 | docker: 45 | - image: rollupcabal/circleci-node-base:latest 46 | steps: 47 | - checkout 48 | - restore_cache: 49 | key: dependency-cache-{{ checksum "package-lock.json" }} 50 | - run: 51 | name: NPM Rebuild 52 | command: npm install 53 | - run: 54 | name: Run linting. 55 | command: npm run lint 56 | - run: 57 | name: Run NSP Security Check. 58 | command: npm run security 59 | - run: 60 | name: Validate Commit Messages 61 | command: npm run ci:lint:commits 62 | workflows: 63 | version: 2 64 | validate: 65 | jobs: 66 | - dependency_cache 67 | - analysis: 68 | requires: 69 | - dependency_cache 70 | filters: 71 | tags: 72 | only: /.*/ 73 | - node-v10-latest: 74 | requires: 75 | - analysis 76 | filters: 77 | tags: 78 | only: /.*/ 79 | -------------------------------------------------------------------------------- /lib/plugin.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2018 Andrew Powell 3 | 4 | This Source Code Form is subject to the terms of the Mozilla Public 5 | License, v. 2.0. If a copy of the MPL was not distributed with this 6 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | The above copyright notice and this permission notice shall be 9 | included in all copies or substantial portions of this Source Code Form. 10 | */ 11 | /* eslint-disable no-param-reassign */ 12 | const { dirname } = require('path'); 13 | 14 | const isObject = require('is-plain-obj'); 15 | const pkgConf = require('pkg-conf'); 16 | const { WebpackPluginServe } = require('webpack-plugin-serve'); 17 | 18 | const { prepare } = require('./flags'); 19 | 20 | const applyEntry = (entry) => { 21 | const pluginEntry = 'webpack-plugin-serve/client'; 22 | 23 | if (Array.isArray(entry)) { 24 | entry.push(pluginEntry); 25 | } else if (isObject(entry)) { 26 | const keys = Object.keys(entry); 27 | for (const key of keys) { 28 | entry[key] = applyEntry(entry[key]); 29 | } 30 | } else { 31 | entry = [entry, pluginEntry]; 32 | } 33 | 34 | return entry; 35 | }; 36 | 37 | const applyPlugin = (config, flags, plugin, attach = false) => { 38 | const isEmpty = Object.keys(config).length === 0; 39 | 40 | if (!config.plugins) { 41 | config.plugins = []; 42 | } 43 | 44 | config.plugins.push(attach ? plugin.attach() : plugin); 45 | 46 | if (isEmpty) { 47 | config.entry = ['./src']; 48 | } 49 | 50 | // apply watch only if hmr or liveReload is on, if it's the first config, and if --no-watch is not 51 | // specified 52 | if (!attach && flags.watch !== false) { 53 | config.watch = true; 54 | } 55 | 56 | config.entry = applyEntry(config.entry); 57 | 58 | return config; 59 | }; 60 | 61 | const apply = async (config, flags, configPath) => { 62 | const flagOptions = prepare(flags); 63 | const pkgConfig = await pkgConf('serve', { cwd: dirname(configPath) }); 64 | const options = Object.assign({}, pkgConfig, flagOptions); 65 | const plugin = new WebpackPluginServe(options); 66 | 67 | if (flags.all) { 68 | if (Array.isArray(config)) { 69 | config = config.map((c, index) => applyPlugin(c, flags, plugin, index > 0)); 70 | } else { 71 | config = applyPlugin(config, flags, plugin); 72 | } 73 | } else { 74 | [config] = [].concat(config); 75 | config = applyPlugin(config, flags, plugin); 76 | } 77 | 78 | return config; 79 | }; 80 | 81 | module.exports = { apply }; 82 | -------------------------------------------------------------------------------- /.github/labels.json: -------------------------------------------------------------------------------- 1 | [ 2 | { "name": "💩 template incomplete", "color": "#4E342E" }, 3 | { "name": "💩 template removed", "color": "#4E342E" }, 4 | 5 | { "name": "c¹ ⋅ discussion", "color": "#1976D2" }, 6 | { "name": "c² ⋅ feedback wanted", "color": "#F9A825" }, 7 | { "name": "c³ ⋅ PR welcome", "color": "#1B5E20" }, 8 | { "name": "c⁴ ⋅ need more info", "color": "#6A1B9A" }, 9 | { "name": "c⁵ ⋅ question", "color": "#C2185B" }, 10 | { "name": "c⁶ ⋅ request for comments", "color": "#BBDEFB" }, 11 | 12 | { "name": "p¹ ⋅ electron", "color": "#B2DFDB" }, 13 | { "name": "p² ⋅ linux", "color": "#B2DFDB" }, 14 | { "name": "p³ ⋅ mac", "color": "#B2DFDB" }, 15 | { "name": "p⁴ ⋅ windows", "color": "#B2DFDB" }, 16 | 17 | { "name": "pr¹ 🔧 chore", "color": "#D7CCC8" }, 18 | { "name": "pr² 🔧 docs", "color": "#D7CCC8" }, 19 | { "name": "pr³ 🔧 feature", "color": "#D7CCC8" }, 20 | { "name": "pr⁴ 🔧 fix", "color": "#D7CCC8" }, 21 | { "name": "pr⁵ 🔧 performance", "color": "#D7CCC8" }, 22 | { "name": "pr⁶ 🔧 refactor", "color": "#D7CCC8" }, 23 | { "name": "pr⁷ 🔧 style", "color": "#D7CCC8" }, 24 | { "name": "pr⁸ 🔧 test", "color": "#D7CCC8" }, 25 | 26 | { "name": "s¹ 🔥🔥🔥 critical", "color": "#E53935" }, 27 | { "name": "s² 🔥🔥 important", "color": "#FB8C00" }, 28 | { "name": "s³ 🔥 nice to have", "color": "#FDD835" }, 29 | { "name": "s⁴ 💧 low", "color": "#039BE5" }, 30 | { "name": "s⁵ 💧💧 inconvenient", "color": "#c0e0f7" }, 31 | 32 | { "name": "t¹ 🐞 bug", "color": "#F44336" }, 33 | { "name": "t² 📚 documentation", "color": "#FDD835" }, 34 | { "name": "t³ ✨ enhancement", "color": "#03a9f4" }, 35 | { "name": "t⁴ ✨ feature", "color": "#8bc34A" }, 36 | { "name": "t⁵ ⋅ regression", "color": "#0052cc" }, 37 | { "name": "t⁶ ⋅ todo", "color": "#311B92" }, 38 | { "name": "t⁷ ⋅ waiting on upstream", "color": "#0D47A1" }, 39 | 40 | { "name": "v¹ ⋅ alpha", "color": "#CDDC39" }, 41 | { "name": "v² ⋅ beta", "color": "#FFEB3B" }, 42 | { "name": "v³ ⋅ major", "color": "#FF9800" }, 43 | { "name": "v⁴ ⋅ minor", "color": "#FFC107" }, 44 | { "name": "v⁵ ⋅ next", "color": "#CDDC39" }, 45 | 46 | { "name": "x¹ ⋅ abandoned", "color": "#CFD8DC" }, 47 | { "name": "x² ⋅ could not reproduce", "color": "#CFD8DC" }, 48 | { "name": "x³ ⋅ duplicate", "color": "#CFD8DC" }, 49 | { "name": "x⁴ ⋅ hold", "color": "#CFD8DC" }, 50 | { "name": "x⁵ ⋅ in progress", "color": "#4CAF50" }, 51 | { "name": "x⁶ ⋅ invalid", "color": "#CFD8DC" }, 52 | { "name": "x⁷ ⋅ wontfix", "color": "#CFD8DC" } 53 | ] 54 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack-serve", 3 | "version": "4.0.0", 4 | "description": "A CLI for webpack-plugin-serve, providing a premier webpack development server", 5 | "license": "MIT", 6 | "repository": "shellscape/webpack-serve", 7 | "author": "Andrew Powell ", 8 | "homepage": "https://github.com/shellscape/webpack-serve", 9 | "bugs": "https://github.com/shellscape/webpack-serve/issues", 10 | "bin": "bin/webpack-serve", 11 | "engines": { 12 | "node": ">= 8.0.0 < 9.0.0 || >= 10.0.0 < 10.14.0 || >= 10.15.0" 13 | }, 14 | "scripts": { 15 | "ci:coverage": "nyc npm run test --verbose && nyc report --reporter=text-lcov > coverage.lcov", 16 | "ci:lint": "npm run lint && npm run security", 17 | "ci:lint:commits": "commitlint --from=${CIRCLE_BRANCH} --to=${CIRCLE_SHA1}", 18 | "ci:test": "npm run test -- --verbose", 19 | "commitlint": "commitlint", 20 | "commitmsg": "commitlint -e $GIT_PARAMS", 21 | "lint": "eslint --fix --cache bin/* lib test", 22 | "lint-staged": "lint-staged", 23 | "security": "npm audit --audit-level=moderate", 24 | "test": "ava" 25 | }, 26 | "files": [ 27 | "bin/", 28 | "lib/", 29 | "LICENSE", 30 | "README.md" 31 | ], 32 | "peerDependencies": { 33 | "webpack": "^4.29.0" 34 | }, 35 | "dependencies": { 36 | "chalk": "^4.1.0", 37 | "decamelize": "^5.0.0", 38 | "import-local": "^3.0.1", 39 | "is-plain-obj": "^3.0.0", 40 | "object-path": "^0.11.5", 41 | "pkg-conf": "^3.0.0", 42 | "rechoir": "^0.7.0", 43 | "v8-compile-cache": "^2.0.2", 44 | "webpack-plugin-serve": "^1.4.1", 45 | "yargs-parser": "^20.2.7" 46 | }, 47 | "devDependencies": { 48 | "@babel/preset-env": "^7.2.0", 49 | "@babel/register": "^7.0.0", 50 | "@commitlint/cli": "^12.0.1", 51 | "@commitlint/config-conventional": "^12.0.1", 52 | "ava": "^2.4.0", 53 | "eslint-config-shellscape": "^3.0.0", 54 | "execa": "^5.0.0", 55 | "get-port": "^5.0.0", 56 | "lint-staged": "^10.5.4", 57 | "nyc": "^15.1.0", 58 | "pre-commit": "^1.2.2", 59 | "prettier": "^2.2.1", 60 | "puppeteer": "^1.13.0", 61 | "standard-version": "^9.1.1", 62 | "strip-ansi": "^6.0.0", 63 | "webpack": "^4.29.6", 64 | "webpack-nano": "^1.1.1" 65 | }, 66 | "keywords": [ 67 | "development", 68 | "devserver", 69 | "serve", 70 | "server", 71 | "webpack" 72 | ], 73 | "ava": { 74 | "files": [ 75 | "!**/fixtures/**", 76 | "!**/helpers/**" 77 | ] 78 | }, 79 | "lint-staged": { 80 | "*.js": [ 81 | "eslint --fix", 82 | "git add" 83 | ] 84 | }, 85 | "nyc": { 86 | "include": [ 87 | "lib/*.js" 88 | ], 89 | "exclude": [ 90 | "lib/client*.js", 91 | "test/" 92 | ] 93 | }, 94 | "pre-commit": "lint-staged" 95 | } 96 | -------------------------------------------------------------------------------- /lib/config.js: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright © 2018 Andrew Powell 3 | 4 | This Source Code Form is subject to the terms of the Mozilla Public 5 | License, v. 2.0. If a copy of the MPL was not distributed with this 6 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 7 | 8 | The above copyright notice and this permission notice shall be 9 | included in all copies or substantial portions of this Source Code Form. 10 | */ 11 | const { existsSync } = require('fs'); 12 | const { resolve } = require('path'); 13 | 14 | const rechoir = require('rechoir'); 15 | 16 | const { apply } = require('./plugin'); 17 | 18 | const fileTypes = { 19 | '.babel.js': ['@babel/register', 'babel-register', 'babel-core/register', 'babel/register'], 20 | '.babel.ts': ['@babel/register'], 21 | '.es6': ['@babel/register'], 22 | '.mjs': ['@babel/register'], 23 | '.ts': [ 24 | 'ts-node/register', 25 | 'typescript-node/register', 26 | 'typescript-register', 27 | 'typescript-require' 28 | ] 29 | }; 30 | const configTypes = { 31 | function: (c, argv) => Promise.resolve(c(argv.env || {}, argv)), 32 | object: (c) => Promise.resolve(c) 33 | }; 34 | const cwd = process.cwd(); 35 | const defaultConfigPath = resolve(cwd, 'webpack.config.js'); 36 | 37 | const requireLoader = (extension) => { 38 | try { 39 | rechoir.prepare(fileTypes, `config${extension}`, cwd); 40 | } catch (e) { 41 | let message; 42 | if (/no module loader/i.test(e.message)) { 43 | const [, fileType] = e.message.match(/(".+").$/); 44 | message = `A loader could not be found for the ${fileType} file type`; 45 | } else { 46 | const modules = e.failures.map(({ moduleName }) => `\n ${moduleName}`); 47 | message = `${e.message.slice(0, -1)}:${modules}`; 48 | } 49 | 50 | const error = new RangeError(message); 51 | error.code = 'ERR_MODULE_LOADER'; 52 | throw error; 53 | } 54 | }; 55 | 56 | const loadConfig = async (argv) => { 57 | if (!argv.config && existsSync(defaultConfigPath)) { 58 | // eslint-disable-next-line no-param-reassign 59 | argv.config = defaultConfigPath; 60 | } 61 | 62 | // let's not process any config if the user hasn't specified any 63 | if (argv.config) { 64 | const configName = typeof argv.config !== 'string' ? Object.keys(argv.config)[0] : null; 65 | // e.g. --config.batman webpack.config.js 66 | const configPath = argv.config[configName] || argv.config; 67 | const resolvedPath = resolve(configPath); 68 | 69 | // only register a loader if the config file extension matches one we support 70 | const extension = Object.keys(fileTypes).find((t) => resolvedPath.endsWith(t)); 71 | 72 | if (extension) { 73 | requireLoader(extension); 74 | } 75 | 76 | let configExport = require(resolvedPath); // eslint-disable-line global-require, import/no-dynamic-require 77 | 78 | if (configExport.default) { 79 | configExport = configExport.default; 80 | } 81 | 82 | if (configName) { 83 | if (!Array.isArray(configExport)) { 84 | throw new TypeError( 85 | `A config with name was specified, but the config ${configPath} does not export an Array.` 86 | ); 87 | } 88 | 89 | configExport = configExport.find((c) => c.name === configName); 90 | 91 | if (!configExport) { 92 | throw new RangeError(`A config with name '${configName}' was not found in ${configPath}`); 93 | } 94 | } 95 | 96 | const configType = typeof configExport; 97 | let config = await configTypes[configType](configExport, argv); 98 | config = await apply(config, argv, resolvedPath); 99 | 100 | const watchConfig = [].concat(config).find((c) => !!c.watch); 101 | const result = { config, watchConfig }; 102 | 103 | return result; 104 | } 105 | 106 | return { config: await apply({}, argv, process.cwd()) }; 107 | }; 108 | 109 | module.exports = { loadConfig }; 110 | -------------------------------------------------------------------------------- /bin/webpack-serve: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | /* 4 | Copyright © 2018 Andrew Powell 5 | 6 | This Source Code Form is subject to the terms of the Mozilla Public 7 | License, v. 2.0. If a copy of the MPL was not distributed with this 8 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 9 | 10 | The above copyright notice and this permission notice shall be 11 | included in all copies or substantial portions of this Source Code Form. 12 | */ 13 | // require('v8-compile-cache'); 14 | 15 | const chalk = require('chalk'); 16 | const importLocal = require('import-local'); 17 | const parse = require('yargs-parser'); 18 | const webpack = require('webpack'); 19 | 20 | const pkg = require('../package.json'); 21 | const { check } = require('../lib/flags'); 22 | const { run } = require('../lib/compiler'); 23 | const { loadConfig } = require('../lib/config'); 24 | 25 | const { error: stderr } = console; 26 | const end = () => process.exit(0); 27 | 28 | const help = chalk` 29 | ${pkg.description} 30 | 31 | {underline Usage} 32 | $ webpack-serve [...options] 33 | 34 | {underline Options} 35 | --all Apply webpack-plugin-serve to all compilers in the config 36 | --client.address Overrides the WebSocket address in the client 37 | --client.retry Instructs the client to attempt to reconnect all WebSockets when interrupted 38 | --client.silent Instructs the client not to log anything to the console 39 | --compress Enables compression middleware which serves files with GZip compression 40 | --config A path to a webpack config file 41 | --config.\{name\} A path to a webpack config file, and the config name to run 42 | --help Displays this message 43 | --history-fallback Enables History API Fallback 44 | --hmr Enables Hot Module Replacement. On by default 45 | --host Sets the host the server should listen from 46 | --http2 Instructs the server to enable HTTP2 47 | --live-reload Instructs the client to perform a full page reload after each build 48 | --no-watch Does not apply \`watch: true\` to the config, allowing for greater customization 49 | --open Opens the default browser to the set host and port 50 | --port Sets the port on which the server should listen 51 | --progress Shows build progress in the client 52 | --silent Instruct the CLI to produce no console output 53 | --static Sets the directory from which static files will be served 54 | --status Shows build status (errors, warnings) in the client 55 | --version Displays webpack-nano and webpack versions 56 | --wait-for-build Instructs the server to halt middleware processing until the current build is done 57 | 58 | {underline Examples} 59 | $ webpack-serve 60 | $ webpack-serve --help 61 | $ webpack-serve --config webpack.config.js 62 | $ webpack-serve --config.serve webpack.config.js 63 | `; 64 | 65 | const doeet = async () => { 66 | process.on('SIGINT', end); 67 | process.on('SIGTERM', end); 68 | 69 | const argv = parse(process.argv.slice(2)); 70 | const logPrefix = { ok: chalk.blue('⬡ webpack:'), whoops: chalk.red('⬢ webpack:') }; 71 | const log = { 72 | error: (...args) => { 73 | if (argv.silent) return; 74 | args.unshift(logPrefix.whoops); 75 | stderr(...args); 76 | }, 77 | info: (...args) => { 78 | if (argv.silent) return; 79 | args.unshift(logPrefix.ok); 80 | stderr(...args); 81 | } 82 | }; 83 | 84 | check(argv); 85 | 86 | if (argv.help) { 87 | stderr(help); 88 | return; 89 | } 90 | 91 | if (argv.version || argv.v) { 92 | stderr(` 93 | webpack-serve v${pkg.version} 94 | webpack v${webpack.version} 95 | `); 96 | return; 97 | } 98 | 99 | const config = await loadConfig(argv); 100 | 101 | run(config, log); 102 | }; 103 | 104 | process.on('unhandledRejection', (err) => { 105 | stderr(err.stack); 106 | process.exitCode = 1; 107 | }); 108 | 109 | // eslint-disable-next-line no-unused-expressions 110 | importLocal(__filename) || doeet(); 111 | -------------------------------------------------------------------------------- /assets/serve.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 9 | 10 | 11 | 18 | 19 | 20 | 23 | 27 | 28 | 35 | 38 | 39 | 40 | 41 | 42 | 43 | 48 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [tests]: https://img.shields.io/circleci/project/github/shellscape/webpack-serve.svg 2 | [tests-url]: https://circleci.com/gh/shellscape/webpack-serve 3 | 4 | [cover]: https://codecov.io/gh/shellscape/webpack-serve/branch/master/graph/badge.svg 5 | [cover-url]: https://codecov.io/gh/shellscape/webpack-serve 6 | 7 | [size]: https://packagephobia.now.sh/badge?p=webpack-serve 8 | [size-url]: https://packagephobia.now.sh/result?p=webpack-serve 9 | 10 | [https]: https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener 11 | [http2]: https://nodejs.org/api/http2.html#http2_http2_createserver_options_onrequesthandler 12 | [http2tls]: https://nodejs.org/api/http2.html#http2_http2_createsecureserver_options_onrequesthandler 13 | 14 |
15 | webpack-serve

16 |
17 | 18 | [![tests][tests]][tests-url] 19 | [![cover][cover]][cover-url] 20 | [![size][size]][size-url] 21 | 22 | # webpack-serve 23 | 24 | A CLI for [`webpack-plugin-serve`](https://github.com/shellscape/webpack-plugin-serve) - A Webpack development server in a plugin. 25 | 26 | _(While using a CLI such as webpack-serve is convenient, we recommend using [`webpack-plugin-serve`](https://github.com/shellscape/webpack-plugin-serve) directly in your webpack config, with [`webpack-nano`](https://github.com/shellscape/webpack-nano), instead.)_ 27 | 28 | 29 | 30 | 31 | 32 | _Please consider donating if you find this project useful._ 33 | 34 | ## Requirements 35 | 36 | `webpack-serve` is an [evergreen 🌲](./.github/FAQ.md#what-does-evergreen-mean) module. 37 | 38 | This module requires an [Active LTS](https://github.com/nodejs/Release) Node version (v8.0.0+ or v10.0.0+). The client scripts in this module require [browsers which support `async/await`](https://caniuse.com/#feat=async-functions). Users may also choose to compile the client script via an appropriately configured [Babel](https://babeljs.io/) webpack loader for use in older browsers. 39 | 40 | ## Feature Parity 41 | 42 | Since this CLI leverages `webpack-plugin-serve`, the same feature parity information applies. Please see the [`webpack-plugin-serve` Feature Comparison](https://github.com/shellscape/webpack-plugin-serve/blob/HEAD/.github/FEATURES.md) for more information. 43 | 44 | ## Install 45 | 46 | Using npm: 47 | 48 | ```console 49 | npm install webpack-serve --save-dev 50 | ``` 51 | 52 | ## Usage 53 | 54 | ```console 55 | A CLI for webpack-plugin-serve, providing a premier webpack development server 56 | 57 | Usage 58 | $ webpack-serve [...options] 59 | 60 | Options 61 | --all Apply webpack-plugin-serve to all compilers in the config 62 | --client.address Overrides the WebSocket address in the client 63 | --client.retry Instructs the client to attempt to reconnect all WebSockets when interrupted 64 | --client.silent Instructs the client not to log anything to the console. 65 | --compress Enables compression middleware which serves files with GZip compression. 66 | --config A path to a webpack config file 67 | --config.{name} A path to a webpack config file, and the config name to run 68 | --help Displays this message 69 | --history-fallback Enables History API Fallback 70 | --hmr Enables Hot Module Replacement. On by default 71 | --host Sets the host the server should listen from 72 | --http2 Instructs the server to enable HTTP2 73 | --live-reload Instructs the client to perform a full page reload after each build 74 | --no-watch Does not apply \`watch: true\` to the config, allowing for greater customization 75 | --open Opens the default browser to the set host and port 76 | --port Sets the port on which the server should listen 77 | --progress Shows build progress in the client 78 | --silent Instruct the CLI to produce no console output 79 | --static Sets the directory from which static files will be served 80 | --status Shows build status (errors, warnings) in the client 81 | --version Displays webpack-nano and webpack versions 82 | --wait-for-build Instructs the server to halt middleware processing until the current build is done. 83 | 84 | Examples 85 | $ webpack-serve 86 | $ webpack-serve --help 87 | $ webpack-serve --config webpack.config.js 88 | $ webpack-serve --config.serve webpack.config.js 89 | ``` 90 | 91 | ## Flags 92 | 93 | Please reference the [`webpack-plugin-serve` Options](https://github.com/shellscape/webpack-plugin-serve#options) for information and use. Most options are analogous to the flags listed above. 94 | 95 | #### `--no-watch` 96 | 97 | By default, the CLI will apply `watch: true` to the first config in the targeted webpack config file. To customize watching or `watchOptions`, please use this flag and customize the config(s) accordingly. 98 | 99 | ## package.json Options 100 | 101 | For convenience, `webpack-plugin-serve` options can also be defined in a `package.json` file. This CLI will look for a `serve` key in the nearest `package.json` beginning in the directory containing the specified `webpack.config.js`, up to the current working directory. Please reference the [`webpack-plugin-serve` Options](https://github.com/shellscape/webpack-plugin-serve#options) for information and use. 102 | 103 | For Example: 104 | 105 | ```json 106 | { 107 | "name": "some-package", 108 | "version": "1.0.0", 109 | "serve": { 110 | "host": "10.10.10.1" 111 | } 112 | } 113 | ``` 114 | 115 | ## Advanced Options 116 | 117 | For options which require providing functions or complex objects like `Promises` which cannot be represented by JSON, nor on the command line, please use [`webpack-plugin-serve`](https://github.com/shellscape/webpack-plugin-serve) directly in your webpack config, along with [`webpack-nano`](https://github.com/shellscape/webpack-nano). 118 | 119 | ## Meta 120 | 121 | [CONTRIBUTING](./.github/CONTRIBUTING.md) 122 | 123 | [LICENSE (Mozilla Public License)](./LICENSE) 124 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License Version 2.0 2 | ================================== 3 | 4 | 1. Definitions 5 | -------------- 6 | 7 | 1.1. "Contributor" 8 | means each individual or legal entity that creates, contributes to 9 | the creation of, or owns Covered Software. 10 | 11 | 1.2. "Contributor Version" 12 | means the combination of the Contributions of others (if any) used 13 | by a Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | means Covered Software of a particular Contributor. 17 | 18 | 1.4. "Covered Software" 19 | means Source Code Form to which the initial Contributor has attached 20 | the notice in Exhibit A, the Executable Form of such Source Code 21 | Form, and Modifications of such Source Code Form, in each case 22 | including portions thereof. 23 | 24 | 1.5. "Incompatible With Secondary Licenses" 25 | means 26 | 27 | (a) that the initial Contributor has attached the notice described 28 | in Exhibit B to the Covered Software; or 29 | 30 | (b) that the Covered Software was made available under the terms of 31 | version 1.1 or earlier of the License, but not also under the 32 | terms of a Secondary License. 33 | 34 | 1.6. "Executable Form" 35 | means any form of the work other than Source Code Form. 36 | 37 | 1.7. "Larger Work" 38 | means a work that combines Covered Software with other material, in 39 | a separate file or files, that is not Covered Software. 40 | 41 | 1.8. "License" 42 | means this document. 43 | 44 | 1.9. "Licensable" 45 | means having the right to grant, to the maximum extent possible, 46 | whether at the time of the initial grant or subsequently, any and 47 | all of the rights conveyed by this License. 48 | 49 | 1.10. "Modifications" 50 | means any of the following: 51 | 52 | (a) any file in Source Code Form that results from an addition to, 53 | deletion from, or modification of the contents of Covered 54 | Software; or 55 | 56 | (b) any new file in Source Code Form that contains any Covered 57 | Software. 58 | 59 | 1.11. "Patent Claims" of a Contributor 60 | means any patent claim(s), including without limitation, method, 61 | process, and apparatus claims, in any patent Licensable by such 62 | Contributor that would be infringed, but for the grant of the 63 | License, by the making, using, selling, offering for sale, having 64 | made, import, or transfer of either its Contributions or its 65 | Contributor Version. 66 | 67 | 1.12. "Secondary License" 68 | means either the GNU General Public License, Version 2.0, the GNU 69 | Lesser General Public License, Version 2.1, the GNU Affero General 70 | Public License, Version 3.0, or any later versions of those 71 | licenses. 72 | 73 | 1.13. "Source Code Form" 74 | means the form of the work preferred for making modifications. 75 | 76 | 1.14. "You" (or "Your") 77 | means an individual or a legal entity exercising rights under this 78 | License. For legal entities, "You" includes any entity that 79 | controls, is controlled by, or is under common control with You. For 80 | purposes of this definition, "control" means (a) the power, direct 81 | or indirect, to cause the direction or management of such entity, 82 | whether by contract or otherwise, or (b) ownership of more than 83 | fifty percent (50%) of the outstanding shares or beneficial 84 | ownership of such entity. 85 | 86 | 2. License Grants and Conditions 87 | -------------------------------- 88 | 89 | 2.1. Grants 90 | 91 | Each Contributor hereby grants You a world-wide, royalty-free, 92 | non-exclusive license: 93 | 94 | (a) under intellectual property rights (other than patent or trademark) 95 | Licensable by such Contributor to use, reproduce, make available, 96 | modify, display, perform, distribute, and otherwise exploit its 97 | Contributions, either on an unmodified basis, with Modifications, or 98 | as part of a Larger Work; and 99 | 100 | (b) under Patent Claims of such Contributor to make, use, sell, offer 101 | for sale, have made, import, and otherwise transfer either its 102 | Contributions or its Contributor Version. 103 | 104 | 2.2. Effective Date 105 | 106 | The licenses granted in Section 2.1 with respect to any Contribution 107 | become effective for each Contribution on the date the Contributor first 108 | distributes such Contribution. 109 | 110 | 2.3. Limitations on Grant Scope 111 | 112 | The licenses granted in this Section 2 are the only rights granted under 113 | this License. No additional rights or licenses will be implied from the 114 | distribution or licensing of Covered Software under this License. 115 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 116 | Contributor: 117 | 118 | (a) for any code that a Contributor has removed from Covered Software; 119 | or 120 | 121 | (b) for infringements caused by: (i) Your and any other third party's 122 | modifications of Covered Software, or (ii) the combination of its 123 | Contributions with other software (except as part of its Contributor 124 | Version); or 125 | 126 | (c) under Patent Claims infringed by Covered Software in the absence of 127 | its Contributions. 128 | 129 | This License does not grant any rights in the trademarks, service marks, 130 | or logos of any Contributor (except as may be necessary to comply with 131 | the notice requirements in Section 3.4). 132 | 133 | 2.4. Subsequent Licenses 134 | 135 | No Contributor makes additional grants as a result of Your choice to 136 | distribute the Covered Software under a subsequent version of this 137 | License (see Section 10.2) or under the terms of a Secondary License (if 138 | permitted under the terms of Section 3.3). 139 | 140 | 2.5. Representation 141 | 142 | Each Contributor represents that the Contributor believes its 143 | Contributions are its original creation(s) or it has sufficient rights 144 | to grant the rights to its Contributions conveyed by this License. 145 | 146 | 2.6. Fair Use 147 | 148 | This License is not intended to limit any rights You have under 149 | applicable copyright doctrines of fair use, fair dealing, or other 150 | equivalents. 151 | 152 | 2.7. Conditions 153 | 154 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted 155 | in Section 2.1. 156 | 157 | 3. Responsibilities 158 | ------------------- 159 | 160 | 3.1. Distribution of Source Form 161 | 162 | All distribution of Covered Software in Source Code Form, including any 163 | Modifications that You create or to which You contribute, must be under 164 | the terms of this License. You must inform recipients that the Source 165 | Code Form of the Covered Software is governed by the terms of this 166 | License, and how they can obtain a copy of this License. You may not 167 | attempt to alter or restrict the recipients' rights in the Source Code 168 | Form. 169 | 170 | 3.2. Distribution of Executable Form 171 | 172 | If You distribute Covered Software in Executable Form then: 173 | 174 | (a) such Covered Software must also be made available in Source Code 175 | Form, as described in Section 3.1, and You must inform recipients of 176 | the Executable Form how they can obtain a copy of such Source Code 177 | Form by reasonable means in a timely manner, at a charge no more 178 | than the cost of distribution to the recipient; and 179 | 180 | (b) You may distribute such Executable Form under the terms of this 181 | License, or sublicense it under different terms, provided that the 182 | license for the Executable Form does not attempt to limit or alter 183 | the recipients' rights in the Source Code Form under this License. 184 | 185 | 3.3. Distribution of a Larger Work 186 | 187 | You may create and distribute a Larger Work under terms of Your choice, 188 | provided that You also comply with the requirements of this License for 189 | the Covered Software. If the Larger Work is a combination of Covered 190 | Software with a work governed by one or more Secondary Licenses, and the 191 | Covered Software is not Incompatible With Secondary Licenses, this 192 | License permits You to additionally distribute such Covered Software 193 | under the terms of such Secondary License(s), so that the recipient of 194 | the Larger Work may, at their option, further distribute the Covered 195 | Software under the terms of either this License or such Secondary 196 | License(s). 197 | 198 | 3.4. Notices 199 | 200 | You may not remove or alter the substance of any license notices 201 | (including copyright notices, patent notices, disclaimers of warranty, 202 | or limitations of liability) contained within the Source Code Form of 203 | the Covered Software, except that You may alter any license notices to 204 | the extent required to remedy known factual inaccuracies. 205 | 206 | 3.5. Application of Additional Terms 207 | 208 | You may choose to offer, and to charge a fee for, warranty, support, 209 | indemnity or liability obligations to one or more recipients of Covered 210 | Software. However, You may do so only on Your own behalf, and not on 211 | behalf of any Contributor. You must make it absolutely clear that any 212 | such warranty, support, indemnity, or liability obligation is offered by 213 | You alone, and You hereby agree to indemnify every Contributor for any 214 | liability incurred by such Contributor as a result of warranty, support, 215 | indemnity or liability terms You offer. You may include additional 216 | disclaimers of warranty and limitations of liability specific to any 217 | jurisdiction. 218 | 219 | 4. Inability to Comply Due to Statute or Regulation 220 | --------------------------------------------------- 221 | 222 | If it is impossible for You to comply with any of the terms of this 223 | License with respect to some or all of the Covered Software due to 224 | statute, judicial order, or regulation then You must: (a) comply with 225 | the terms of this License to the maximum extent possible; and (b) 226 | describe the limitations and the code they affect. Such description must 227 | be placed in a text file included with all distributions of the Covered 228 | Software under this License. Except to the extent prohibited by statute 229 | or regulation, such description must be sufficiently detailed for a 230 | recipient of ordinary skill to be able to understand it. 231 | 232 | 5. Termination 233 | -------------- 234 | 235 | 5.1. The rights granted under this License will terminate automatically 236 | if You fail to comply with any of its terms. However, if You become 237 | compliant, then the rights granted under this License from a particular 238 | Contributor are reinstated (a) provisionally, unless and until such 239 | Contributor explicitly and finally terminates Your grants, and (b) on an 240 | ongoing basis, if such Contributor fails to notify You of the 241 | non-compliance by some reasonable means prior to 60 days after You have 242 | come back into compliance. Moreover, Your grants from a particular 243 | Contributor are reinstated on an ongoing basis if such Contributor 244 | notifies You of the non-compliance by some reasonable means, this is the 245 | first time You have received notice of non-compliance with this License 246 | from such Contributor, and You become compliant prior to 30 days after 247 | Your receipt of the notice. 248 | 249 | 5.2. If You initiate litigation against any entity by asserting a patent 250 | infringement claim (excluding declaratory judgment actions, 251 | counter-claims, and cross-claims) alleging that a Contributor Version 252 | directly or indirectly infringes any patent, then the rights granted to 253 | You by any and all Contributors for the Covered Software under Section 254 | 2.1 of this License shall terminate. 255 | 256 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all 257 | end user license agreements (excluding distributors and resellers) which 258 | have been validly granted by You or Your distributors under this License 259 | prior to termination shall survive termination. 260 | 261 | ************************************************************************ 262 | * * 263 | * 6. Disclaimer of Warranty * 264 | * ------------------------- * 265 | * * 266 | * Covered Software is provided under this License on an "as is" * 267 | * basis, without warranty of any kind, either expressed, implied, or * 268 | * statutory, including, without limitation, warranties that the * 269 | * Covered Software is free of defects, merchantable, fit for a * 270 | * particular purpose or non-infringing. The entire risk as to the * 271 | * quality and performance of the Covered Software is with You. * 272 | * Should any Covered Software prove defective in any respect, You * 273 | * (not any Contributor) assume the cost of any necessary servicing, * 274 | * repair, or correction. This disclaimer of warranty constitutes an * 275 | * essential part of this License. No use of any Covered Software is * 276 | * authorized under this License except under this disclaimer. * 277 | * * 278 | ************************************************************************ 279 | 280 | ************************************************************************ 281 | * * 282 | * 7. Limitation of Liability * 283 | * -------------------------- * 284 | * * 285 | * Under no circumstances and under no legal theory, whether tort * 286 | * (including negligence), contract, or otherwise, shall any * 287 | * Contributor, or anyone who distributes Covered Software as * 288 | * permitted above, be liable to You for any direct, indirect, * 289 | * special, incidental, or consequential damages of any character * 290 | * including, without limitation, damages for lost profits, loss of * 291 | * goodwill, work stoppage, computer failure or malfunction, or any * 292 | * and all other commercial damages or losses, even if such party * 293 | * shall have been informed of the possibility of such damages. This * 294 | * limitation of liability shall not apply to liability for death or * 295 | * personal injury resulting from such party's negligence to the * 296 | * extent applicable law prohibits such limitation. Some * 297 | * jurisdictions do not allow the exclusion or limitation of * 298 | * incidental or consequential damages, so this exclusion and * 299 | * limitation may not apply to You. * 300 | * * 301 | ************************************************************************ 302 | 303 | 8. Litigation 304 | ------------- 305 | 306 | Any litigation relating to this License may be brought only in the 307 | courts of a jurisdiction where the defendant maintains its principal 308 | place of business and such litigation shall be governed by laws of that 309 | jurisdiction, without reference to its conflict-of-law provisions. 310 | Nothing in this Section shall prevent a party's ability to bring 311 | cross-claims or counter-claims. 312 | 313 | 9. Miscellaneous 314 | ---------------- 315 | 316 | This License represents the complete agreement concerning the subject 317 | matter hereof. If any provision of this License is held to be 318 | unenforceable, such provision shall be reformed only to the extent 319 | necessary to make it enforceable. Any law or regulation which provides 320 | that the language of a contract shall be construed against the drafter 321 | shall not be used to construe this License against a Contributor. 322 | 323 | 10. Versions of the License 324 | --------------------------- 325 | 326 | 10.1. New Versions 327 | 328 | Mozilla Foundation is the license steward. Except as provided in Section 329 | 10.3, no one other than the license steward has the right to modify or 330 | publish new versions of this License. Each version will be given a 331 | distinguishing version number. 332 | 333 | 10.2. Effect of New Versions 334 | 335 | You may distribute the Covered Software under the terms of the version 336 | of the License under which You originally received the Covered Software, 337 | or under the terms of any subsequent version published by the license 338 | steward. 339 | 340 | 10.3. Modified Versions 341 | 342 | If you create software not governed by this License, and you want to 343 | create a new license for such software, you may create and use a 344 | modified version of this License if you rename the license and remove 345 | any references to the name of the license steward (except to note that 346 | such modified license differs from this License). 347 | 348 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 349 | Licenses 350 | 351 | If You choose to distribute Source Code Form that is Incompatible With 352 | Secondary Licenses under the terms of this version of the License, the 353 | notice described in Exhibit B of this License must be attached. 354 | 355 | Exhibit A - Source Code Form License Notice 356 | ------------------------------------------- 357 | 358 | This Source Code Form is subject to the terms of the Mozilla Public 359 | License, v. 2.0. If a copy of the MPL was not distributed with this 360 | file, You can obtain one at http://mozilla.org/MPL/2.0/. 361 | 362 | If it is not possible or desirable to put the notice in a particular 363 | file, then You may include the notice in a location (such as a LICENSE 364 | file in a relevant directory) where a recipient would be likely to look 365 | for such a notice. 366 | 367 | You may add additional accurate notices of copyright ownership. 368 | 369 | Exhibit B - "Incompatible With Secondary Licenses" Notice 370 | --------------------------------------------------------- 371 | 372 | This Source Code Form is "Incompatible With Secondary Licenses", as 373 | defined by the Mozilla Public License, v. 2.0. 374 | --------------------------------------------------------------------------------