├── .babelrc ├── test └── assets │ ├── content.js │ ├── style.css │ ├── entry.js │ ├── index.html │ └── bundle.js ├── .gitignore ├── rollup.config.js ├── src ├── os-browsers.json └── webpack-browser-plugin.js ├── webpack.config.js ├── package.json ├── README.md └── lib └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["es2015-rollup"] 3 | } -------------------------------------------------------------------------------- /test/assets/content.js: -------------------------------------------------------------------------------- 1 | module.exports = 'This is my content.js.'; -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .idea 3 | .DS_Store 4 | npm-debug.log 5 | test/bundle.js 6 | -------------------------------------------------------------------------------- /test/assets/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | background: slategrey; 3 | color: blueviolet; 4 | } -------------------------------------------------------------------------------- /test/assets/entry.js: -------------------------------------------------------------------------------- 1 | require("!style!css!./style.css"); 2 | document.write(require("./content.js")); 3 | console.log('Hello'); 4 | -------------------------------------------------------------------------------- /test/assets/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import babel from 'rollup-plugin-babel'; 2 | import json from 'rollup-plugin-json'; 3 | 4 | export default { 5 | entry: 'src/webpack-browser-plugin.js', 6 | format: 'cjs', 7 | plugins: [ 8 | json(), 9 | babel() 10 | ], 11 | dest: 'lib/index.js' 12 | }; 13 | -------------------------------------------------------------------------------- /src/os-browsers.json: -------------------------------------------------------------------------------- 1 | { 2 | "aix": {}, 3 | "darwin": { 4 | "google": { 5 | "app": "google chrome" 6 | }, 7 | "firefox": { 8 | "app": "firefox" 9 | } 10 | }, 11 | "freebsd": {}, 12 | "linux": { 13 | "google": { 14 | "app": "google-chrome" 15 | } 16 | }, 17 | "openbsd": {}, 18 | "sunos": {}, 19 | "win32": { 20 | "google": { 21 | "app": "chrome" 22 | }, 23 | "firefox": { 24 | "app": "firefox" 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | 4 | var WebpackBrowserPlugin = require('./lib'); 5 | 6 | module.exports = { 7 | entry: path.resolve(__dirname, 'test/assets/entry.js'), 8 | output: { 9 | path: path.resolve(__dirname, 'test'), 10 | filename: 'bundle.js', 11 | publicPath: '/assets/' 12 | }, 13 | devServer: { 14 | contentBase: path.resolve(__dirname, 'test') 15 | }, 16 | module: { 17 | loaders: [ 18 | {test: /\.css$/, loader: 'style!css'} 19 | ] 20 | }, 21 | plugins: [ 22 | new WebpackBrowserPlugin({ 23 | port: null, 24 | publicPath: '/', 25 | browser: 'default', 26 | url: 'localhost:8080', 27 | openOptions: null, 28 | bsOptions: null 29 | }), 30 | new webpack.HotModuleReplacementPlugin() 31 | ] 32 | }; 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack-browser-plugin", 3 | "version": "1.0.19", 4 | "description": "Launch a browser after webpack-dev-server completes building", 5 | "main": "lib/index.js", 6 | "scripts": { 7 | "test": "webpack", 8 | "test:dev": "webpack-dev-server --progress", 9 | "build": "rollup -c", 10 | "webpack": "webpack --progress", 11 | "webpack-dev-server": "webpack-dev-server --progress" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/1337programming/webpack-browser-plugin.git" 16 | }, 17 | "license": "ISC", 18 | "bugs": { 19 | "url": "https://github.com/1337programming/webpack-browser-plugin/issues" 20 | }, 21 | "homepage": "https://github.com/1337programming/webpack-browser-plugin", 22 | "devDependencies": { 23 | "babel-core": "^6.7.7", 24 | "babel-preset-es2015-rollup": "^1.1.1", 25 | "css-loader": "^0.23.1", 26 | "html-loader": "^0.4.3", 27 | "rollup": "^0.25.8", 28 | "rollup-plugin-babel": "^2.4.0", 29 | "rollup-plugin-json": "^2.0.1", 30 | "style-loader": "^0.13.1", 31 | "webpack": "^1.13.1", 32 | "webpack-dev-server": "^1.16.2" 33 | }, 34 | "dependencies": { 35 | "browser-sync": "^2.13.0", 36 | "opn": "^4.0.2" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![npm version](https://badge.fury.io/js/webpack-browser-plugin.svg)](https://badge.fury.io/js/webpack-browser-plugin) 2 | ![](https://reposs.herokuapp.com/?path=1337programming/webpack-browser-plugin) 3 | [![npm](https://img.shields.io/npm/dm/webpack-browser-plugin.svg)]() 4 | # Webpack Browser Plugin 5 | 6 | This plugin enables your webpack builds to automatically launch it's application on a browser. 7 | 8 | Will automatically work for webpack-dev-server. For standard webpack usage -- browser sync is used to launch the application on a specific port. 9 | 10 | ## Installation 11 | 12 | `npm install --save-dev webpack-browser-plugin` 13 | 14 | ## Setup 15 | In `webpack.config.js`: 16 | 17 | ```js 18 | const WebpackBrowserPlugin = require('webpack-browser-plugin'); 19 | 20 | module.exports = { 21 | ... 22 | ... 23 | plugins: [ 24 | new WebpackBrowserPlugin() 25 | ], 26 | ... 27 | } 28 | ``` 29 | 30 | 31 | 32 | ## Example 33 | 34 | You can specify a port and a browser to be used. 35 | 36 | ```js 37 | const WebpackBrowserPlugin = require('webpack-browser-plugin'); 38 | 39 | var plugins = []; 40 | 41 | plugins.push(new WebpackBrowserPlugin({ 42 | browser: 'Firefox', 43 | port: 9000, 44 | url: 'http://192.168.3.1' 45 | })); 46 | 47 | var config = { 48 | entry: { 49 | app: __dirname + 'src/pantera.js' 50 | }, 51 | output: { 52 | path: __dirname + 'dest' 53 | }, 54 | devServer: { 55 | contentBase: __dirname + 'dest' 56 | }, 57 | plugins: plugins, 58 | module: { 59 | loaders: [ 60 | {test: /\.js$/, loaders: 'babel'}, 61 | {test: /\.scss$/, loader: 'style!css!scss?'}, 62 | {test: /\.html$/, loader: 'html-loader'} 63 | ] 64 | } 65 | } 66 | 67 | module.exports = config; 68 | ``` 69 | 70 | Note: For `webpack`, `browser-sync` is being used. For `webpack-dev-server` a child process spawns the browser popup. 71 | Also ports get overwritten if specified in webpack.config.js for webpack-dev-server. 72 | 73 | ### Other Webpack Plugins 74 | Also checkout our other webpack plugin [WebpackShellPlugin](https://github.com/1337programming/webpack-shell-plugin). 75 | 76 | ### API 77 | * `port`: Port to run on. **Default: 8080 ** 78 | * `browser`: Browser to use. Note: webpack-dev-server will open your default browser. **Default: default ** 79 | * `url`: Url to use. **Default: http://127.0.0.1 or http://localhost ** 80 | * `publicPath`: Public url path. Note: this gets overridden by output.publicPath in your webpack.config. **Default: null** 81 | 82 | **Webpack-dev-server** only 83 | * `openOptions`: For webpack-dev-server, we use node module [opn](https://github.com/sindresorhus/opn). WARNING: This will override this plugin and webpack's configurations. **Default: null** 84 | 85 | **Webpack** only 86 | * `bsOptions`: Options to pass to the [browser-sync module](https://browsersync.io/docs/options). WARNING: This will override this plugin and webpack's configurations. **Default: null** 87 | 88 | ### Contributing 89 | Create a new branch and write your changes in the `src/` folder. 90 | 91 | Make sure you run your tests with both `webpack` and `webpack-dev-server`. Or `npm run test` and `npm run test:dev`. 92 | 93 | Once complete run `npm run build` and create your pull request. 94 | -------------------------------------------------------------------------------- /src/webpack-browser-plugin.js: -------------------------------------------------------------------------------- 1 | import os from 'os'; 2 | 3 | import OsBrowsers from './os-browsers.json'; 4 | 5 | export default class WebpackBrowserPlugin { 6 | 7 | static cleanPublicPath(str) { 8 | let arr = str.split(''); 9 | if (arr[0] === '/') { 10 | arr.splice(0, 1); 11 | } 12 | if (arr[arr.length - 1] === '/') { 13 | arr.splice(arr.length - 1, 1); 14 | } 15 | return arr.join(''); 16 | } 17 | 18 | constructor(options) { 19 | const defaultOptions = { 20 | port: 8080, 21 | browser: 'default', 22 | url: null, 23 | publicPath: '', 24 | proxy: null, 25 | openOptions: null, 26 | bsOptions: null 27 | }; 28 | if (options) { 29 | this.options = this.mergeOptions(options, defaultOptions); 30 | } else { 31 | this.options = defaultOptions; 32 | } 33 | this.firstRun = true; 34 | this.watch = false; 35 | this.dev = null; 36 | this.outputPath = null; 37 | } 38 | 39 | mergeOptions(options, defaults) { 40 | for (let key in defaults) { 41 | if (options.hasOwnProperty(key)) { 42 | defaults[key] = options[key]; 43 | } 44 | } 45 | return defaults; 46 | } 47 | 48 | browserStr(browser) { 49 | browser = browser.toLowerCase(); 50 | let valid = false; 51 | if (browser.indexOf('google') > -1 || browser.indexOf('chrome') > -1) { 52 | if (OsBrowsers[os.platform()].google) { 53 | browser = OsBrowsers[os.platform()].google.app; 54 | valid = true; 55 | } 56 | } 57 | if (browser.indexOf('fire') > -1 || browser.indexOf('fox') > -1) { 58 | if (OsBrowsers[os.platform()].firefox) { 59 | browser = OsBrowsers[os.platform()].firefox.app; 60 | valid = true; 61 | } 62 | } 63 | return {browser: browser, valid: valid}; 64 | } 65 | 66 | buildUrl(options) { 67 | let url = options.url; 68 | if (this.options.url) { 69 | url = this.options.url; 70 | if (this.options.publicPath) { 71 | return `${url}/${this.options.publicPath}`; 72 | } 73 | } else { 74 | if (!!~options.url.indexOf('${port}')) { 75 | let url = options.url.replace('${port}', `:${options.port}`); 76 | return `${url}/${this.options.publicPath}`; 77 | } else if (options.port) { 78 | return `${options.url}:${options.port.toString()}/${this.options.publicPath}`; 79 | } else { 80 | return `${options.url}/${this.options.publicPath}`; 81 | } 82 | } 83 | } 84 | 85 | apply(compiler) { 86 | if (compiler.options.output.publicPath) { 87 | this.options.publicPath = WebpackBrowserPlugin.cleanPublicPath(compiler.options.output.publicPath); 88 | } 89 | if (compiler.options.port) { 90 | this.options.port = compiler.options.port; 91 | } else if (compiler.options.devServer) { 92 | if (compiler.options.devServer.port) { 93 | this.options.port = compiler.options.devServer.port; 94 | } 95 | } 96 | 97 | compiler.plugin('compilation', (compilation) => { 98 | if (compilation.options.watch) { 99 | this.watch = true; 100 | } 101 | if (compilation.compiler._plugins['watch-run']) { 102 | this.dev = true; 103 | } else { 104 | this.dev = false; 105 | this.outputPath = compilation.compiler.outputPath; 106 | console.log('outputPath', this.outputPath); 107 | } 108 | }); 109 | 110 | compiler.plugin('done', (compilation) => { 111 | if (this.firstRun) { 112 | if (this.dev === true) { 113 | const open = require('opn'); 114 | const url = this.buildUrl(this.options); 115 | let results = this.browserStr(this.options.browser); 116 | if (this.options.openOptions) { 117 | open(url, this.options.openOptions); 118 | } else { 119 | if (results.valid) { 120 | open(url, {app: results.browser}); 121 | } else { 122 | open(url); 123 | if (results.browser !== 'default') { 124 | console.log(`Given browser params: '${this.options.browser}' were not valid or available. Default browser opened.`); 125 | } 126 | } 127 | } 128 | } else if (this.dev === false) { 129 | const bs = require('browser-sync').create(); 130 | 131 | if (this.watch) { 132 | bs.watch(this.outputPath + '/**/*.js', (event, file) => { 133 | if (event === "change") { 134 | bs.reload(); 135 | } 136 | }); 137 | } 138 | bs.init(this.buildBSServer()); 139 | } else { 140 | console.log('Failed Plugin: Webpack-Broswer-Plugin, incorrect params found.'); 141 | } 142 | this.firstRun = false; 143 | } 144 | }); 145 | } 146 | 147 | buildBSServer() { 148 | let server = [this.outputPath]; 149 | if (this.options.publicPath && this.options.publicPath !== '') { 150 | server.push(`${this.outputPath}/${this.options.publicPath}`); 151 | } 152 | let bsOptions = {}; 153 | if (this.options.bsOptions) { 154 | bsOptions = this.options.bsOptions; 155 | } else { 156 | bsOptions.server = server; 157 | bsOptions.browser = this.options.browser; 158 | bsOptions.open = 'internal'; 159 | if (this.options.publicPath) { 160 | bsOptions.startPath = this.options.publicPath 161 | } 162 | if (this.options.port) { 163 | bsOptions.port = this.options.port; 164 | } 165 | } 166 | 167 | console.log(bsOptions); 168 | 169 | return bsOptions; 170 | } 171 | 172 | } 173 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } 4 | 5 | var os = _interopDefault(require('os')); 6 | 7 | var babelHelpers = {}; 8 | 9 | babelHelpers.classCallCheck = function (instance, Constructor) { 10 | if (!(instance instanceof Constructor)) { 11 | throw new TypeError("Cannot call a class as a function"); 12 | } 13 | }; 14 | 15 | babelHelpers.createClass = function () { 16 | function defineProperties(target, props) { 17 | for (var i = 0; i < props.length; i++) { 18 | var descriptor = props[i]; 19 | descriptor.enumerable = descriptor.enumerable || false; 20 | descriptor.configurable = true; 21 | if ("value" in descriptor) descriptor.writable = true; 22 | Object.defineProperty(target, descriptor.key, descriptor); 23 | } 24 | } 25 | 26 | return function (Constructor, protoProps, staticProps) { 27 | if (protoProps) defineProperties(Constructor.prototype, protoProps); 28 | if (staticProps) defineProperties(Constructor, staticProps); 29 | return Constructor; 30 | }; 31 | }(); 32 | 33 | babelHelpers; 34 | 35 | var aix = {}; 36 | var darwin = { "google": { "app": "google chrome" }, "firefox": { "app": "firefox" } }; 37 | var freebsd = {}; 38 | var linux = { "google": { "app": "google-chrome" } }; 39 | var openbsd = {}; 40 | var sunos = {}; 41 | var win32 = { "google": { "app": "chrome" }, "firefox": { "app": "firefox" } }; 42 | var OsBrowsers = { 43 | aix: aix, 44 | darwin: darwin, 45 | freebsd: freebsd, 46 | linux: linux, 47 | openbsd: openbsd, 48 | sunos: sunos, 49 | win32: win32 50 | }; 51 | 52 | var WebpackBrowserPlugin = function () { 53 | babelHelpers.createClass(WebpackBrowserPlugin, null, [{ 54 | key: 'cleanPublicPath', 55 | value: function cleanPublicPath(str) { 56 | var arr = str.split(''); 57 | if (arr[0] === '/') { 58 | arr.splice(0, 1); 59 | } 60 | if (arr[arr.length - 1] === '/') { 61 | arr.splice(arr.length - 1, 1); 62 | } 63 | return arr.join(''); 64 | } 65 | }]); 66 | 67 | function WebpackBrowserPlugin(options) { 68 | babelHelpers.classCallCheck(this, WebpackBrowserPlugin); 69 | 70 | var defaultOptions = { 71 | port: 8080, 72 | browser: 'default', 73 | url: null, 74 | publicPath: '', 75 | proxy: null, 76 | openOptions: null, 77 | bsOptions: null 78 | }; 79 | if (options) { 80 | this.options = this.mergeOptions(options, defaultOptions); 81 | } else { 82 | this.options = defaultOptions; 83 | } 84 | this.firstRun = true; 85 | this.watch = false; 86 | this.dev = null; 87 | this.outputPath = null; 88 | } 89 | 90 | babelHelpers.createClass(WebpackBrowserPlugin, [{ 91 | key: 'mergeOptions', 92 | value: function mergeOptions(options, defaults) { 93 | for (var key in defaults) { 94 | if (options.hasOwnProperty(key)) { 95 | defaults[key] = options[key]; 96 | } 97 | } 98 | return defaults; 99 | } 100 | }, { 101 | key: 'browserStr', 102 | value: function browserStr(browser) { 103 | browser = browser.toLowerCase(); 104 | var valid = false; 105 | if (browser.indexOf('google') > -1 || browser.indexOf('chrome') > -1) { 106 | if (OsBrowsers[os.platform()].google) { 107 | browser = OsBrowsers[os.platform()].google.app; 108 | valid = true; 109 | } 110 | } 111 | if (browser.indexOf('fire') > -1 || browser.indexOf('fox') > -1) { 112 | if (OsBrowsers[os.platform()].firefox) { 113 | browser = OsBrowsers[os.platform()].firefox.app; 114 | valid = true; 115 | } 116 | } 117 | return { browser: browser, valid: valid }; 118 | } 119 | }, { 120 | key: 'buildUrl', 121 | value: function buildUrl(options) { 122 | var url = options.url; 123 | if (this.options.url) { 124 | url = this.options.url; 125 | if (this.options.publicPath) { 126 | return url + '/' + this.options.publicPath; 127 | } 128 | } else { 129 | if (!! ~options.url.indexOf('${port}')) { 130 | var _url = options.url.replace('${port}', ':' + options.port); 131 | return _url + '/' + this.options.publicPath; 132 | } else if (options.port) { 133 | return options.url + ':' + options.port.toString() + '/' + this.options.publicPath; 134 | } else { 135 | return options.url + '/' + this.options.publicPath; 136 | } 137 | } 138 | } 139 | }, { 140 | key: 'apply', 141 | value: function apply(compiler) { 142 | var _this = this; 143 | 144 | if (compiler.options.output.publicPath) { 145 | this.options.publicPath = WebpackBrowserPlugin.cleanPublicPath(compiler.options.output.publicPath); 146 | } 147 | if (compiler.options.port) { 148 | this.options.port = compiler.options.port; 149 | } else if (compiler.options.devServer) { 150 | if (compiler.options.devServer.port) { 151 | this.options.port = compiler.options.devServer.port; 152 | } 153 | } 154 | 155 | compiler.plugin('compilation', function (compilation) { 156 | if (compilation.options.watch) { 157 | _this.watch = true; 158 | } 159 | if (compilation.compiler._plugins['watch-run']) { 160 | _this.dev = true; 161 | } else { 162 | _this.dev = false; 163 | _this.outputPath = compilation.compiler.outputPath; 164 | console.log('outputPath', _this.outputPath); 165 | } 166 | }); 167 | 168 | compiler.plugin('done', function (compilation) { 169 | if (_this.firstRun) { 170 | if (_this.dev === true) { 171 | var open = require('opn'); 172 | var url = _this.buildUrl(_this.options); 173 | var results = _this.browserStr(_this.options.browser); 174 | if (_this.options.openOptions) { 175 | open(url, _this.options.openOptions); 176 | } else { 177 | if (results.valid) { 178 | open(url, { app: results.browser }); 179 | } else { 180 | open(url); 181 | if (results.browser !== 'default') { 182 | console.log('Given browser params: \'' + _this.options.browser + '\' were not valid or available. Default browser opened.'); 183 | } 184 | } 185 | } 186 | } else if (_this.dev === false) { 187 | (function () { 188 | var bs = require('browser-sync').create(); 189 | 190 | if (_this.watch) { 191 | bs.watch(_this.outputPath + '/**/*.js', function (event, file) { 192 | if (event === "change") { 193 | bs.reload(); 194 | } 195 | }); 196 | } 197 | bs.init(_this.buildBSServer()); 198 | })(); 199 | } else { 200 | console.log('Failed Plugin: Webpack-Broswer-Plugin, incorrect params found.'); 201 | } 202 | _this.firstRun = false; 203 | } 204 | }); 205 | } 206 | }, { 207 | key: 'buildBSServer', 208 | value: function buildBSServer() { 209 | var server = [this.outputPath]; 210 | if (this.options.publicPath && this.options.publicPath !== '') { 211 | server.push(this.outputPath + '/' + this.options.publicPath); 212 | } 213 | var bsOptions = {}; 214 | if (this.options.bsOptions) { 215 | bsOptions = this.options.bsOptions; 216 | } else { 217 | bsOptions.server = server; 218 | bsOptions.browser = this.options.browser; 219 | bsOptions.open = 'internal'; 220 | if (this.options.publicPath) { 221 | bsOptions.startPath = this.options.publicPath; 222 | } 223 | if (this.options.port) { 224 | bsOptions.port = this.options.port; 225 | } 226 | } 227 | 228 | console.log(bsOptions); 229 | 230 | return bsOptions; 231 | } 232 | }]); 233 | return WebpackBrowserPlugin; 234 | }(); 235 | 236 | module.exports = WebpackBrowserPlugin; -------------------------------------------------------------------------------- /test/assets/bundle.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ var parentHotUpdateCallback = this["webpackHotUpdate"]; 3 | /******/ this["webpackHotUpdate"] = 4 | /******/ function webpackHotUpdateCallback(chunkId, moreModules) { // eslint-disable-line no-unused-vars 5 | /******/ hotAddUpdateChunk(chunkId, moreModules); 6 | /******/ if(parentHotUpdateCallback) parentHotUpdateCallback(chunkId, moreModules); 7 | /******/ } 8 | /******/ 9 | /******/ function hotDownloadUpdateChunk(chunkId) { // eslint-disable-line no-unused-vars 10 | /******/ var head = document.getElementsByTagName("head")[0]; 11 | /******/ var script = document.createElement("script"); 12 | /******/ script.type = "text/javascript"; 13 | /******/ script.charset = "utf-8"; 14 | /******/ script.src = __webpack_require__.p + "" + chunkId + "." + hotCurrentHash + ".hot-update.js"; 15 | /******/ head.appendChild(script); 16 | /******/ } 17 | /******/ 18 | /******/ function hotDownloadManifest(callback) { // eslint-disable-line no-unused-vars 19 | /******/ if(typeof XMLHttpRequest === "undefined") 20 | /******/ return callback(new Error("No browser support")); 21 | /******/ try { 22 | /******/ var request = new XMLHttpRequest(); 23 | /******/ var requestPath = __webpack_require__.p + "" + hotCurrentHash + ".hot-update.json"; 24 | /******/ request.open("GET", requestPath, true); 25 | /******/ request.timeout = 10000; 26 | /******/ request.send(null); 27 | /******/ } catch(err) { 28 | /******/ return callback(err); 29 | /******/ } 30 | /******/ request.onreadystatechange = function() { 31 | /******/ if(request.readyState !== 4) return; 32 | /******/ if(request.status === 0) { 33 | /******/ // timeout 34 | /******/ callback(new Error("Manifest request to " + requestPath + " timed out.")); 35 | /******/ } else if(request.status === 404) { 36 | /******/ // no update available 37 | /******/ callback(); 38 | /******/ } else if(request.status !== 200 && request.status !== 304) { 39 | /******/ // other failure 40 | /******/ callback(new Error("Manifest request to " + requestPath + " failed.")); 41 | /******/ } else { 42 | /******/ // success 43 | /******/ try { 44 | /******/ var update = JSON.parse(request.responseText); 45 | /******/ } catch(e) { 46 | /******/ callback(e); 47 | /******/ return; 48 | /******/ } 49 | /******/ callback(null, update); 50 | /******/ } 51 | /******/ }; 52 | /******/ } 53 | 54 | /******/ 55 | /******/ 56 | /******/ // Copied from https://github.com/facebook/react/blob/bef45b0/src/shared/utils/canDefineProperty.js 57 | /******/ var canDefineProperty = false; 58 | /******/ try { 59 | /******/ Object.defineProperty({}, "x", { 60 | /******/ get: function() {} 61 | /******/ }); 62 | /******/ canDefineProperty = true; 63 | /******/ } catch(x) { 64 | /******/ // IE will fail on defineProperty 65 | /******/ } 66 | /******/ 67 | /******/ var hotApplyOnUpdate = true; 68 | /******/ var hotCurrentHash = "c3b9718f1eade9e607c1"; // eslint-disable-line no-unused-vars 69 | /******/ var hotCurrentModuleData = {}; 70 | /******/ var hotCurrentParents = []; // eslint-disable-line no-unused-vars 71 | /******/ 72 | /******/ function hotCreateRequire(moduleId) { // eslint-disable-line no-unused-vars 73 | /******/ var me = installedModules[moduleId]; 74 | /******/ if(!me) return __webpack_require__; 75 | /******/ var fn = function(request) { 76 | /******/ if(me.hot.active) { 77 | /******/ if(installedModules[request]) { 78 | /******/ if(installedModules[request].parents.indexOf(moduleId) < 0) 79 | /******/ installedModules[request].parents.push(moduleId); 80 | /******/ if(me.children.indexOf(request) < 0) 81 | /******/ me.children.push(request); 82 | /******/ } else hotCurrentParents = [moduleId]; 83 | /******/ } else { 84 | /******/ console.warn("[HMR] unexpected require(" + request + ") from disposed module " + moduleId); 85 | /******/ hotCurrentParents = []; 86 | /******/ } 87 | /******/ return __webpack_require__(request); 88 | /******/ }; 89 | /******/ for(var name in __webpack_require__) { 90 | /******/ if(Object.prototype.hasOwnProperty.call(__webpack_require__, name)) { 91 | /******/ if(canDefineProperty) { 92 | /******/ Object.defineProperty(fn, name, (function(name) { 93 | /******/ return { 94 | /******/ configurable: true, 95 | /******/ enumerable: true, 96 | /******/ get: function() { 97 | /******/ return __webpack_require__[name]; 98 | /******/ }, 99 | /******/ set: function(value) { 100 | /******/ __webpack_require__[name] = value; 101 | /******/ } 102 | /******/ }; 103 | /******/ }(name))); 104 | /******/ } else { 105 | /******/ fn[name] = __webpack_require__[name]; 106 | /******/ } 107 | /******/ } 108 | /******/ } 109 | /******/ 110 | /******/ function ensure(chunkId, callback) { 111 | /******/ if(hotStatus === "ready") 112 | /******/ hotSetStatus("prepare"); 113 | /******/ hotChunksLoading++; 114 | /******/ __webpack_require__.e(chunkId, function() { 115 | /******/ try { 116 | /******/ callback.call(null, fn); 117 | /******/ } finally { 118 | /******/ finishChunkLoading(); 119 | /******/ } 120 | /******/ 121 | /******/ function finishChunkLoading() { 122 | /******/ hotChunksLoading--; 123 | /******/ if(hotStatus === "prepare") { 124 | /******/ if(!hotWaitingFilesMap[chunkId]) { 125 | /******/ hotEnsureUpdateChunk(chunkId); 126 | /******/ } 127 | /******/ if(hotChunksLoading === 0 && hotWaitingFiles === 0) { 128 | /******/ hotUpdateDownloaded(); 129 | /******/ } 130 | /******/ } 131 | /******/ } 132 | /******/ }); 133 | /******/ } 134 | /******/ if(canDefineProperty) { 135 | /******/ Object.defineProperty(fn, "e", { 136 | /******/ enumerable: true, 137 | /******/ value: ensure 138 | /******/ }); 139 | /******/ } else { 140 | /******/ fn.e = ensure; 141 | /******/ } 142 | /******/ return fn; 143 | /******/ } 144 | /******/ 145 | /******/ function hotCreateModule(moduleId) { // eslint-disable-line no-unused-vars 146 | /******/ var hot = { 147 | /******/ // private stuff 148 | /******/ _acceptedDependencies: {}, 149 | /******/ _declinedDependencies: {}, 150 | /******/ _selfAccepted: false, 151 | /******/ _selfDeclined: false, 152 | /******/ _disposeHandlers: [], 153 | /******/ 154 | /******/ // Module API 155 | /******/ active: true, 156 | /******/ accept: function(dep, callback) { 157 | /******/ if(typeof dep === "undefined") 158 | /******/ hot._selfAccepted = true; 159 | /******/ else if(typeof dep === "function") 160 | /******/ hot._selfAccepted = dep; 161 | /******/ else if(typeof dep === "object") 162 | /******/ for(var i = 0; i < dep.length; i++) 163 | /******/ hot._acceptedDependencies[dep[i]] = callback; 164 | /******/ else 165 | /******/ hot._acceptedDependencies[dep] = callback; 166 | /******/ }, 167 | /******/ decline: function(dep) { 168 | /******/ if(typeof dep === "undefined") 169 | /******/ hot._selfDeclined = true; 170 | /******/ else if(typeof dep === "number") 171 | /******/ hot._declinedDependencies[dep] = true; 172 | /******/ else 173 | /******/ for(var i = 0; i < dep.length; i++) 174 | /******/ hot._declinedDependencies[dep[i]] = true; 175 | /******/ }, 176 | /******/ dispose: function(callback) { 177 | /******/ hot._disposeHandlers.push(callback); 178 | /******/ }, 179 | /******/ addDisposeHandler: function(callback) { 180 | /******/ hot._disposeHandlers.push(callback); 181 | /******/ }, 182 | /******/ removeDisposeHandler: function(callback) { 183 | /******/ var idx = hot._disposeHandlers.indexOf(callback); 184 | /******/ if(idx >= 0) hot._disposeHandlers.splice(idx, 1); 185 | /******/ }, 186 | /******/ 187 | /******/ // Management API 188 | /******/ check: hotCheck, 189 | /******/ apply: hotApply, 190 | /******/ status: function(l) { 191 | /******/ if(!l) return hotStatus; 192 | /******/ hotStatusHandlers.push(l); 193 | /******/ }, 194 | /******/ addStatusHandler: function(l) { 195 | /******/ hotStatusHandlers.push(l); 196 | /******/ }, 197 | /******/ removeStatusHandler: function(l) { 198 | /******/ var idx = hotStatusHandlers.indexOf(l); 199 | /******/ if(idx >= 0) hotStatusHandlers.splice(idx, 1); 200 | /******/ }, 201 | /******/ 202 | /******/ //inherit from previous dispose call 203 | /******/ data: hotCurrentModuleData[moduleId] 204 | /******/ }; 205 | /******/ return hot; 206 | /******/ } 207 | /******/ 208 | /******/ var hotStatusHandlers = []; 209 | /******/ var hotStatus = "idle"; 210 | /******/ 211 | /******/ function hotSetStatus(newStatus) { 212 | /******/ hotStatus = newStatus; 213 | /******/ for(var i = 0; i < hotStatusHandlers.length; i++) 214 | /******/ hotStatusHandlers[i].call(null, newStatus); 215 | /******/ } 216 | /******/ 217 | /******/ // while downloading 218 | /******/ var hotWaitingFiles = 0; 219 | /******/ var hotChunksLoading = 0; 220 | /******/ var hotWaitingFilesMap = {}; 221 | /******/ var hotRequestedFilesMap = {}; 222 | /******/ var hotAvailibleFilesMap = {}; 223 | /******/ var hotCallback; 224 | /******/ 225 | /******/ // The update info 226 | /******/ var hotUpdate, hotUpdateNewHash; 227 | /******/ 228 | /******/ function toModuleId(id) { 229 | /******/ var isNumber = (+id) + "" === id; 230 | /******/ return isNumber ? +id : id; 231 | /******/ } 232 | /******/ 233 | /******/ function hotCheck(apply, callback) { 234 | /******/ if(hotStatus !== "idle") throw new Error("check() is only allowed in idle status"); 235 | /******/ if(typeof apply === "function") { 236 | /******/ hotApplyOnUpdate = false; 237 | /******/ callback = apply; 238 | /******/ } else { 239 | /******/ hotApplyOnUpdate = apply; 240 | /******/ callback = callback || function(err) { 241 | /******/ if(err) throw err; 242 | /******/ }; 243 | /******/ } 244 | /******/ hotSetStatus("check"); 245 | /******/ hotDownloadManifest(function(err, update) { 246 | /******/ if(err) return callback(err); 247 | /******/ if(!update) { 248 | /******/ hotSetStatus("idle"); 249 | /******/ callback(null, null); 250 | /******/ return; 251 | /******/ } 252 | /******/ 253 | /******/ hotRequestedFilesMap = {}; 254 | /******/ hotAvailibleFilesMap = {}; 255 | /******/ hotWaitingFilesMap = {}; 256 | /******/ for(var i = 0; i < update.c.length; i++) 257 | /******/ hotAvailibleFilesMap[update.c[i]] = true; 258 | /******/ hotUpdateNewHash = update.h; 259 | /******/ 260 | /******/ hotSetStatus("prepare"); 261 | /******/ hotCallback = callback; 262 | /******/ hotUpdate = {}; 263 | /******/ var chunkId = 0; 264 | /******/ { // eslint-disable-line no-lone-blocks 265 | /******/ /*globals chunkId */ 266 | /******/ hotEnsureUpdateChunk(chunkId); 267 | /******/ } 268 | /******/ if(hotStatus === "prepare" && hotChunksLoading === 0 && hotWaitingFiles === 0) { 269 | /******/ hotUpdateDownloaded(); 270 | /******/ } 271 | /******/ }); 272 | /******/ } 273 | /******/ 274 | /******/ function hotAddUpdateChunk(chunkId, moreModules) { // eslint-disable-line no-unused-vars 275 | /******/ if(!hotAvailibleFilesMap[chunkId] || !hotRequestedFilesMap[chunkId]) 276 | /******/ return; 277 | /******/ hotRequestedFilesMap[chunkId] = false; 278 | /******/ for(var moduleId in moreModules) { 279 | /******/ if(Object.prototype.hasOwnProperty.call(moreModules, moduleId)) { 280 | /******/ hotUpdate[moduleId] = moreModules[moduleId]; 281 | /******/ } 282 | /******/ } 283 | /******/ if(--hotWaitingFiles === 0 && hotChunksLoading === 0) { 284 | /******/ hotUpdateDownloaded(); 285 | /******/ } 286 | /******/ } 287 | /******/ 288 | /******/ function hotEnsureUpdateChunk(chunkId) { 289 | /******/ if(!hotAvailibleFilesMap[chunkId]) { 290 | /******/ hotWaitingFilesMap[chunkId] = true; 291 | /******/ } else { 292 | /******/ hotRequestedFilesMap[chunkId] = true; 293 | /******/ hotWaitingFiles++; 294 | /******/ hotDownloadUpdateChunk(chunkId); 295 | /******/ } 296 | /******/ } 297 | /******/ 298 | /******/ function hotUpdateDownloaded() { 299 | /******/ hotSetStatus("ready"); 300 | /******/ var callback = hotCallback; 301 | /******/ hotCallback = null; 302 | /******/ if(!callback) return; 303 | /******/ if(hotApplyOnUpdate) { 304 | /******/ hotApply(hotApplyOnUpdate, callback); 305 | /******/ } else { 306 | /******/ var outdatedModules = []; 307 | /******/ for(var id in hotUpdate) { 308 | /******/ if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) { 309 | /******/ outdatedModules.push(toModuleId(id)); 310 | /******/ } 311 | /******/ } 312 | /******/ callback(null, outdatedModules); 313 | /******/ } 314 | /******/ } 315 | /******/ 316 | /******/ function hotApply(options, callback) { 317 | /******/ if(hotStatus !== "ready") throw new Error("apply() is only allowed in ready status"); 318 | /******/ if(typeof options === "function") { 319 | /******/ callback = options; 320 | /******/ options = {}; 321 | /******/ } else if(options && typeof options === "object") { 322 | /******/ callback = callback || function(err) { 323 | /******/ if(err) throw err; 324 | /******/ }; 325 | /******/ } else { 326 | /******/ options = {}; 327 | /******/ callback = callback || function(err) { 328 | /******/ if(err) throw err; 329 | /******/ }; 330 | /******/ } 331 | /******/ 332 | /******/ function getAffectedStuff(module) { 333 | /******/ var outdatedModules = [module]; 334 | /******/ var outdatedDependencies = {}; 335 | /******/ 336 | /******/ var queue = outdatedModules.slice(); 337 | /******/ while(queue.length > 0) { 338 | /******/ var moduleId = queue.pop(); 339 | /******/ var module = installedModules[moduleId]; 340 | /******/ if(!module || module.hot._selfAccepted) 341 | /******/ continue; 342 | /******/ if(module.hot._selfDeclined) { 343 | /******/ return new Error("Aborted because of self decline: " + moduleId); 344 | /******/ } 345 | /******/ if(moduleId === 0) { 346 | /******/ return; 347 | /******/ } 348 | /******/ for(var i = 0; i < module.parents.length; i++) { 349 | /******/ var parentId = module.parents[i]; 350 | /******/ var parent = installedModules[parentId]; 351 | /******/ if(parent.hot._declinedDependencies[moduleId]) { 352 | /******/ return new Error("Aborted because of declined dependency: " + moduleId + " in " + parentId); 353 | /******/ } 354 | /******/ if(outdatedModules.indexOf(parentId) >= 0) continue; 355 | /******/ if(parent.hot._acceptedDependencies[moduleId]) { 356 | /******/ if(!outdatedDependencies[parentId]) 357 | /******/ outdatedDependencies[parentId] = []; 358 | /******/ addAllToSet(outdatedDependencies[parentId], [moduleId]); 359 | /******/ continue; 360 | /******/ } 361 | /******/ delete outdatedDependencies[parentId]; 362 | /******/ outdatedModules.push(parentId); 363 | /******/ queue.push(parentId); 364 | /******/ } 365 | /******/ } 366 | /******/ 367 | /******/ return [outdatedModules, outdatedDependencies]; 368 | /******/ } 369 | /******/ 370 | /******/ function addAllToSet(a, b) { 371 | /******/ for(var i = 0; i < b.length; i++) { 372 | /******/ var item = b[i]; 373 | /******/ if(a.indexOf(item) < 0) 374 | /******/ a.push(item); 375 | /******/ } 376 | /******/ } 377 | /******/ 378 | /******/ // at begin all updates modules are outdated 379 | /******/ // the "outdated" status can propagate to parents if they don't accept the children 380 | /******/ var outdatedDependencies = {}; 381 | /******/ var outdatedModules = []; 382 | /******/ var appliedUpdate = {}; 383 | /******/ for(var id in hotUpdate) { 384 | /******/ if(Object.prototype.hasOwnProperty.call(hotUpdate, id)) { 385 | /******/ var moduleId = toModuleId(id); 386 | /******/ var result = getAffectedStuff(moduleId); 387 | /******/ if(!result) { 388 | /******/ if(options.ignoreUnaccepted) 389 | /******/ continue; 390 | /******/ hotSetStatus("abort"); 391 | /******/ return callback(new Error("Aborted because " + moduleId + " is not accepted")); 392 | /******/ } 393 | /******/ if(result instanceof Error) { 394 | /******/ hotSetStatus("abort"); 395 | /******/ return callback(result); 396 | /******/ } 397 | /******/ appliedUpdate[moduleId] = hotUpdate[moduleId]; 398 | /******/ addAllToSet(outdatedModules, result[0]); 399 | /******/ for(var moduleId in result[1]) { 400 | /******/ if(Object.prototype.hasOwnProperty.call(result[1], moduleId)) { 401 | /******/ if(!outdatedDependencies[moduleId]) 402 | /******/ outdatedDependencies[moduleId] = []; 403 | /******/ addAllToSet(outdatedDependencies[moduleId], result[1][moduleId]); 404 | /******/ } 405 | /******/ } 406 | /******/ } 407 | /******/ } 408 | /******/ 409 | /******/ // Store self accepted outdated modules to require them later by the module system 410 | /******/ var outdatedSelfAcceptedModules = []; 411 | /******/ for(var i = 0; i < outdatedModules.length; i++) { 412 | /******/ var moduleId = outdatedModules[i]; 413 | /******/ if(installedModules[moduleId] && installedModules[moduleId].hot._selfAccepted) 414 | /******/ outdatedSelfAcceptedModules.push({ 415 | /******/ module: moduleId, 416 | /******/ errorHandler: installedModules[moduleId].hot._selfAccepted 417 | /******/ }); 418 | /******/ } 419 | /******/ 420 | /******/ // Now in "dispose" phase 421 | /******/ hotSetStatus("dispose"); 422 | /******/ var queue = outdatedModules.slice(); 423 | /******/ while(queue.length > 0) { 424 | /******/ var moduleId = queue.pop(); 425 | /******/ var module = installedModules[moduleId]; 426 | /******/ if(!module) continue; 427 | /******/ 428 | /******/ var data = {}; 429 | /******/ 430 | /******/ // Call dispose handlers 431 | /******/ var disposeHandlers = module.hot._disposeHandlers; 432 | /******/ for(var j = 0; j < disposeHandlers.length; j++) { 433 | /******/ var cb = disposeHandlers[j]; 434 | /******/ cb(data); 435 | /******/ } 436 | /******/ hotCurrentModuleData[moduleId] = data; 437 | /******/ 438 | /******/ // disable module (this disables requires from this module) 439 | /******/ module.hot.active = false; 440 | /******/ 441 | /******/ // remove module from cache 442 | /******/ delete installedModules[moduleId]; 443 | /******/ 444 | /******/ // remove "parents" references from all children 445 | /******/ for(var j = 0; j < module.children.length; j++) { 446 | /******/ var child = installedModules[module.children[j]]; 447 | /******/ if(!child) continue; 448 | /******/ var idx = child.parents.indexOf(moduleId); 449 | /******/ if(idx >= 0) { 450 | /******/ child.parents.splice(idx, 1); 451 | /******/ } 452 | /******/ } 453 | /******/ } 454 | /******/ 455 | /******/ // remove outdated dependency from module children 456 | /******/ for(var moduleId in outdatedDependencies) { 457 | /******/ if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) { 458 | /******/ var module = installedModules[moduleId]; 459 | /******/ var moduleOutdatedDependencies = outdatedDependencies[moduleId]; 460 | /******/ for(var j = 0; j < moduleOutdatedDependencies.length; j++) { 461 | /******/ var dependency = moduleOutdatedDependencies[j]; 462 | /******/ var idx = module.children.indexOf(dependency); 463 | /******/ if(idx >= 0) module.children.splice(idx, 1); 464 | /******/ } 465 | /******/ } 466 | /******/ } 467 | /******/ 468 | /******/ // Not in "apply" phase 469 | /******/ hotSetStatus("apply"); 470 | /******/ 471 | /******/ hotCurrentHash = hotUpdateNewHash; 472 | /******/ 473 | /******/ // insert new code 474 | /******/ for(var moduleId in appliedUpdate) { 475 | /******/ if(Object.prototype.hasOwnProperty.call(appliedUpdate, moduleId)) { 476 | /******/ modules[moduleId] = appliedUpdate[moduleId]; 477 | /******/ } 478 | /******/ } 479 | /******/ 480 | /******/ // call accept handlers 481 | /******/ var error = null; 482 | /******/ for(var moduleId in outdatedDependencies) { 483 | /******/ if(Object.prototype.hasOwnProperty.call(outdatedDependencies, moduleId)) { 484 | /******/ var module = installedModules[moduleId]; 485 | /******/ var moduleOutdatedDependencies = outdatedDependencies[moduleId]; 486 | /******/ var callbacks = []; 487 | /******/ for(var i = 0; i < moduleOutdatedDependencies.length; i++) { 488 | /******/ var dependency = moduleOutdatedDependencies[i]; 489 | /******/ var cb = module.hot._acceptedDependencies[dependency]; 490 | /******/ if(callbacks.indexOf(cb) >= 0) continue; 491 | /******/ callbacks.push(cb); 492 | /******/ } 493 | /******/ for(var i = 0; i < callbacks.length; i++) { 494 | /******/ var cb = callbacks[i]; 495 | /******/ try { 496 | /******/ cb(outdatedDependencies); 497 | /******/ } catch(err) { 498 | /******/ if(!error) 499 | /******/ error = err; 500 | /******/ } 501 | /******/ } 502 | /******/ } 503 | /******/ } 504 | /******/ 505 | /******/ // Load self accepted modules 506 | /******/ for(var i = 0; i < outdatedSelfAcceptedModules.length; i++) { 507 | /******/ var item = outdatedSelfAcceptedModules[i]; 508 | /******/ var moduleId = item.module; 509 | /******/ hotCurrentParents = [moduleId]; 510 | /******/ try { 511 | /******/ __webpack_require__(moduleId); 512 | /******/ } catch(err) { 513 | /******/ if(typeof item.errorHandler === "function") { 514 | /******/ try { 515 | /******/ item.errorHandler(err); 516 | /******/ } catch(err) { 517 | /******/ if(!error) 518 | /******/ error = err; 519 | /******/ } 520 | /******/ } else if(!error) 521 | /******/ error = err; 522 | /******/ } 523 | /******/ } 524 | /******/ 525 | /******/ // handle errors in accept handlers and self accepted module load 526 | /******/ if(error) { 527 | /******/ hotSetStatus("fail"); 528 | /******/ return callback(error); 529 | /******/ } 530 | /******/ 531 | /******/ hotSetStatus("idle"); 532 | /******/ callback(null, outdatedModules); 533 | /******/ } 534 | 535 | /******/ // The module cache 536 | /******/ var installedModules = {}; 537 | 538 | /******/ // The require function 539 | /******/ function __webpack_require__(moduleId) { 540 | 541 | /******/ // Check if module is in cache 542 | /******/ if(installedModules[moduleId]) 543 | /******/ return installedModules[moduleId].exports; 544 | 545 | /******/ // Create a new module (and put it into the cache) 546 | /******/ var module = installedModules[moduleId] = { 547 | /******/ exports: {}, 548 | /******/ id: moduleId, 549 | /******/ loaded: false, 550 | /******/ hot: hotCreateModule(moduleId), 551 | /******/ parents: hotCurrentParents, 552 | /******/ children: [] 553 | /******/ }; 554 | 555 | /******/ // Execute the module function 556 | /******/ modules[moduleId].call(module.exports, module, module.exports, hotCreateRequire(moduleId)); 557 | 558 | /******/ // Flag the module as loaded 559 | /******/ module.loaded = true; 560 | 561 | /******/ // Return the exports of the module 562 | /******/ return module.exports; 563 | /******/ } 564 | 565 | 566 | /******/ // expose the modules object (__webpack_modules__) 567 | /******/ __webpack_require__.m = modules; 568 | 569 | /******/ // expose the module cache 570 | /******/ __webpack_require__.c = installedModules; 571 | 572 | /******/ // __webpack_public_path__ 573 | /******/ __webpack_require__.p = "/assets/"; 574 | 575 | /******/ // __webpack_hash__ 576 | /******/ __webpack_require__.h = function() { return hotCurrentHash; }; 577 | 578 | /******/ // Load entry module and return exports 579 | /******/ return hotCreateRequire(0)(0); 580 | /******/ }) 581 | /************************************************************************/ 582 | /******/ ([ 583 | /* 0 */ 584 | /***/ function(module, exports, __webpack_require__) { 585 | 586 | __webpack_require__(1); 587 | document.write(__webpack_require__(5)); 588 | console.log('Hello'); 589 | 590 | 591 | /***/ }, 592 | /* 1 */ 593 | /***/ function(module, exports, __webpack_require__) { 594 | 595 | // style-loader: Adds some css to the DOM by adding a