├── .gitignore ├── .npmignore ├── example ├── src │ ├── index.js │ └── second-chunk.js ├── webpack.config.js └── dist │ ├── index.bundle.js.map │ ├── second-chunk.bundle.js.map │ ├── index.bundle.js │ └── second-chunk.bundle.js ├── .babelrc ├── LICENSE ├── package.json ├── README.md └── src └── index.js /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | node_modules/ -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | .babelrc 3 | example/ -------------------------------------------------------------------------------- /example/src/index.js: -------------------------------------------------------------------------------- 1 | console.log('index'); -------------------------------------------------------------------------------- /example/src/second-chunk.js: -------------------------------------------------------------------------------- 1 | console.log('second-chunk'); -------------------------------------------------------------------------------- /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env"], 3 | "plugins": ["@babel/plugin-syntax-dynamic-import"] 4 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Alexandr Zahorovskyi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack-dynamic-public-path", 3 | "version": "1.0.8", 4 | "description": "Webpack dynamic public path plugin.", 5 | "main": "./src/index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "build": "node ./node_modules/webpack/bin/webpack --config example/webpack.config.js --display-modules --verbose" 9 | }, 10 | "author": "Oleksandr Zahorovskyi (https://github.com/zahorovskyi)", 11 | "license": "MIT", 12 | "bugs": { 13 | "url": "https://github.com/zahorovskyi/webpack-dynamic-public-path/issues" 14 | }, 15 | "homepage": "https://github.com/zahorovskyi/webpack-dynamic-public-path", 16 | "repository": { 17 | "type": "git", 18 | "url": "https://github.com/zahorovskyi/webpack-dynamic-public-path.git" 19 | }, 20 | "devDependencies": { 21 | "@babel/core": "^7.13.10", 22 | "@babel/plugin-syntax-dynamic-import": "^7.8.3", 23 | "@babel/preset-env": "^7.13.10", 24 | "babel-loader": "^8.2.2", 25 | "clean-webpack-plugin": "^1.0.1", 26 | "webpack": "^4.46.0", 27 | "webpack-cli": "^3.3.12" 28 | }, 29 | "keywords": [ 30 | "webpack", 31 | "publicPath", 32 | "dynamic publicPath" 33 | ] 34 | } 35 | -------------------------------------------------------------------------------- /example/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | 3 | const CleanWebpackPlugin = require('clean-webpack-plugin'); 4 | 5 | const WebpackDynamicPublicPath = require('../src'); 6 | 7 | module.exports = { 8 | entry: { 9 | 'index': path.resolve(__dirname, 'src', 'index.js'), 10 | 'second-chunk': path.resolve(__dirname, 'src', 'second-chunk.js') 11 | }, 12 | output: { 13 | path: path.resolve(__dirname, 'dist'), 14 | filename: '[name].bundle.js', 15 | publicPath: 'publicPathPlaceholder' 16 | }, 17 | module: { 18 | rules: [ 19 | { 20 | test: /\.(js)$/, 21 | include: [ 22 | path.resolve(__dirname, 'src') 23 | ], 24 | exclude: [ 25 | path.resolve(__dirname, '../node_modules') 26 | ], 27 | loader: require.resolve('babel-loader'), 28 | options: { 29 | presets: ['@babel/preset-env'], 30 | plugins: ['@babel/plugin-syntax-dynamic-import'] 31 | } 32 | } 33 | ] 34 | }, 35 | resolve: { 36 | modules: [ 37 | 'node_modules', 38 | path.resolve(__dirname, 'src') 39 | ], 40 | extensions: ['.js', '.json', '.jsx', '.css'] 41 | }, 42 | mode: 'development', 43 | optimization: { 44 | minimize: false 45 | }, 46 | devtool: 'cheap-module-source-map', 47 | context: __dirname, 48 | target: 'web', 49 | stats: 'errors-only', 50 | plugins: [ 51 | new CleanWebpackPlugin('dist'), 52 | new WebpackDynamicPublicPath({ 53 | externalPublicPath: 'window.externalPublicPath', 54 | chunkNames: ['index'] 55 | }), 56 | new WebpackDynamicPublicPath({ 57 | externalPublicPath: '"./"', 58 | chunkNames: ['second-chunk'] 59 | }) 60 | ] 61 | }; -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Dynamic Public Path Plugin 2 | 3 | Replace publicPath inside a chunk, or chunks, to a variable. 4 | 5 | [![NPM](https://nodei.co/npm/webpack-dynamic-public-path.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/webpack-dynamic-public-path/) 6 | 7 | ## Usage 8 | 9 | > :warning: This plugin is compatible only with webpack 4. If you use webpack 5 - check official guide https://webpack.js.org/guides/public-path/#automatic-publicpath 10 | 11 | **webpack.config.js** 12 | ```js 13 | const WebpackDynamicPublicPathPlugin = require("webpack-dynamic-public-path"); 14 | 15 | module.exports = { 16 | output: { 17 | publicPath: "publicPathPlaceholder", 18 | }, 19 | plugins: [ 20 | new WebpackDynamicPublicPathPlugin({ 21 | externalPublicPath: "window.externalPublicPath" 22 | }), 23 | ] 24 | } 25 | ``` 26 | 27 | **bundle.js** 28 | ```js 29 | // before 30 | __webpack_require__.p = "publicPathPlaceholder"; 31 | 32 | // after 33 | __webpack_require__.p = window.externalPublicPath; 34 | ``` 35 | 36 | ## Options 37 | 38 | ```ts 39 | interface Options { 40 | externalPublicPath: string; // JavaScript code, here you can define some variable or condition. 41 | chunkNames: string[]; // Chunk names in which `publicPath` will be replaced. 42 | } 43 | 44 | new WebpackDynamicPublicPathPlugin(options: Options); 45 | ``` 46 | 47 | ### `chunkNames` 48 | 49 | In case if you have several entries you should define plugin instance for each of them. 50 | Check example. 51 | 52 | **webpack.config.js** 53 | ```js 54 | const WebpackDynamicPublicPathPlugin = require("webpack-dynamic-public-path"); 55 | 56 | module.exports = { 57 | entry: { 58 | 'index': path.resolve(__dirname, 'src', 'index.js'), 59 | 'second-chunk': path.resolve(__dirname, 'src', 'second-chunk.js') 60 | }, 61 | output: { 62 | filename: '[name].bundle.js', 63 | publicPath: "publicPathPlaceholder" 64 | }, 65 | plugins: [ 66 | new WebpackDynamicPublicPathPlugin({ 67 | externalPublicPath: "window.externalPublicPathForMainChunk", 68 | chunkNames: ['index'] 69 | }), 70 | new WebpackDynamicPublicPathPlugin({ 71 | externalPublicPath: '"./"', 72 | chunkNames: ['second-chunk'] 73 | }), 74 | ] 75 | } 76 | ``` 77 | 78 | **index.bundle.js** 79 | ```js 80 | __webpack_require__.p = window.externalPublicPathForMainChunk; 81 | ``` 82 | 83 | **second-chunk.bundle.js** 84 | ```js 85 | __webpack_require__.p = "./"; 86 | ``` 87 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | class WebpackDynamicPublicPath { 4 | 5 | /** 6 | * 7 | * @param {Object} options 8 | * @param {string} options.externalPublicPath - variable with new publicPath 9 | * @param {Array} [options.chunkNames] - list of chuck names in which publicPath will be replaced, 10 | * in case if parameter is not defined publicPath will be replaced for all chunks 11 | */ 12 | constructor(options) { 13 | this.options = options; 14 | 15 | this.afterPlugins = this.afterPlugins.bind(this); 16 | this.emit = this.emit.bind(this); 17 | } 18 | 19 | apply(compiler) { 20 | compiler.hooks.afterPlugins.tap({name: 'WebpackDynamicPublicPath'}, this.afterPlugins); 21 | compiler.hooks.emit.tapPromise({name: 'WebpackDynamicPublicPath'}, this.emit); 22 | } 23 | 24 | afterPlugins(compilation) { 25 | if (typeof compilation.options.output === 'undefined' || typeof compilation.options.output.publicPath === 'undefined') { 26 | throw new Error('WebpackDynamicPublicPath: params missing - output.publicPath must be defined in webpack config (used only as placeholder, make it distinctive)'); 27 | } 28 | 29 | if (typeof this.options === 'undefined' || typeof this.options.externalPublicPath === 'undefined') { 30 | throw new Error(`WebpackDynamicPublicPath: params missing - externalPublicPath - name of global variable you want to use as publicPath.`); 31 | } 32 | 33 | this.publicPath = `"${compilation.options.output.publicPath}"`; 34 | } 35 | 36 | emit(compilation) { 37 | const chunks = this.options.chunkNames ? 38 | compilation.chunks.filter(chunk => this.options.chunkNames.includes(chunk.name)) : 39 | compilation.chunks; 40 | 41 | if (!chunks.length) { 42 | throw new Error('WebpackDynamicPublicPath: chunks array for replacing publicPath is empty.'); 43 | } 44 | 45 | const fileNames = chunks.map( 46 | chunk => chunk.files.find( 47 | file => file.match(/.*\.js/) 48 | ) 49 | ); 50 | 51 | const replacePromises = fileNames.map(fileName => this.replacePublicPath(fileName, compilation)); 52 | 53 | return Promise.all(replacePromises).then(() => console.log('WebpackDynamicPublicPath: publicPath replaced.')); 54 | } 55 | 56 | /** 57 | * Replace publicPath 58 | * @param {string} fileName 59 | * @param {object} compilation 60 | * @return {Promise} 61 | */ 62 | replacePublicPath(fileName, compilation) { 63 | return new Promise((resolve) => { 64 | const source = compilation.assets[fileName].source(); 65 | const publicPath = this.publicPath; 66 | const externalPublicPath = this.options.externalPublicPath; 67 | 68 | compilation.assets[fileName].source = function () { 69 | return source.replace(publicPath, externalPublicPath); 70 | }; 71 | 72 | resolve(); 73 | }); 74 | } 75 | } 76 | 77 | 78 | module.exports = WebpackDynamicPublicPath; -------------------------------------------------------------------------------- /example/dist/index.bundle.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"index.bundle.js","sources":["webpack:///webpack/bootstrap","webpack:///./src/index.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"publicPathPlaceholder\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.js\");\n","console.log('index');"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AClFA;;;;A","sourceRoot":""} -------------------------------------------------------------------------------- /example/dist/second-chunk.bundle.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"file":"second-chunk.bundle.js","sources":["webpack:///webpack/bootstrap","webpack:///./src/second-chunk.js"],"sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"publicPathPlaceholder\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/second-chunk.js\");\n","console.log('second-chunk');"],"mappings":";AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;;;;;;;;AClFA;;;;A","sourceRoot":""} -------------------------------------------------------------------------------- /example/dist/index.bundle.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = window.externalPublicPath; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = "./src/index.js"); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ "./src/index.js": 90 | /*!**********************!*\ 91 | !*** ./src/index.js ***! 92 | \**********************/ 93 | /*! no static exports found */ 94 | /***/ (function(module, exports) { 95 | 96 | console.log('index'); 97 | 98 | /***/ }) 99 | 100 | /******/ }); 101 | //# sourceMappingURL=index.bundle.js.map -------------------------------------------------------------------------------- /example/dist/second-chunk.bundle.js: -------------------------------------------------------------------------------- 1 | /******/ (function(modules) { // webpackBootstrap 2 | /******/ // The module cache 3 | /******/ var installedModules = {}; 4 | /******/ 5 | /******/ // The require function 6 | /******/ function __webpack_require__(moduleId) { 7 | /******/ 8 | /******/ // Check if module is in cache 9 | /******/ if(installedModules[moduleId]) { 10 | /******/ return installedModules[moduleId].exports; 11 | /******/ } 12 | /******/ // Create a new module (and put it into the cache) 13 | /******/ var module = installedModules[moduleId] = { 14 | /******/ i: moduleId, 15 | /******/ l: false, 16 | /******/ exports: {} 17 | /******/ }; 18 | /******/ 19 | /******/ // Execute the module function 20 | /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); 21 | /******/ 22 | /******/ // Flag the module as loaded 23 | /******/ module.l = true; 24 | /******/ 25 | /******/ // Return the exports of the module 26 | /******/ return module.exports; 27 | /******/ } 28 | /******/ 29 | /******/ 30 | /******/ // expose the modules object (__webpack_modules__) 31 | /******/ __webpack_require__.m = modules; 32 | /******/ 33 | /******/ // expose the module cache 34 | /******/ __webpack_require__.c = installedModules; 35 | /******/ 36 | /******/ // define getter function for harmony exports 37 | /******/ __webpack_require__.d = function(exports, name, getter) { 38 | /******/ if(!__webpack_require__.o(exports, name)) { 39 | /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); 40 | /******/ } 41 | /******/ }; 42 | /******/ 43 | /******/ // define __esModule on exports 44 | /******/ __webpack_require__.r = function(exports) { 45 | /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { 46 | /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); 47 | /******/ } 48 | /******/ Object.defineProperty(exports, '__esModule', { value: true }); 49 | /******/ }; 50 | /******/ 51 | /******/ // create a fake namespace object 52 | /******/ // mode & 1: value is a module id, require it 53 | /******/ // mode & 2: merge all properties of value into the ns 54 | /******/ // mode & 4: return value when already ns object 55 | /******/ // mode & 8|1: behave like require 56 | /******/ __webpack_require__.t = function(value, mode) { 57 | /******/ if(mode & 1) value = __webpack_require__(value); 58 | /******/ if(mode & 8) return value; 59 | /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; 60 | /******/ var ns = Object.create(null); 61 | /******/ __webpack_require__.r(ns); 62 | /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); 63 | /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); 64 | /******/ return ns; 65 | /******/ }; 66 | /******/ 67 | /******/ // getDefaultExport function for compatibility with non-harmony modules 68 | /******/ __webpack_require__.n = function(module) { 69 | /******/ var getter = module && module.__esModule ? 70 | /******/ function getDefault() { return module['default']; } : 71 | /******/ function getModuleExports() { return module; }; 72 | /******/ __webpack_require__.d(getter, 'a', getter); 73 | /******/ return getter; 74 | /******/ }; 75 | /******/ 76 | /******/ // Object.prototype.hasOwnProperty.call 77 | /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; 78 | /******/ 79 | /******/ // __webpack_public_path__ 80 | /******/ __webpack_require__.p = "./"; 81 | /******/ 82 | /******/ 83 | /******/ // Load entry module and return exports 84 | /******/ return __webpack_require__(__webpack_require__.s = "./src/second-chunk.js"); 85 | /******/ }) 86 | /************************************************************************/ 87 | /******/ ({ 88 | 89 | /***/ "./src/second-chunk.js": 90 | /*!*****************************!*\ 91 | !*** ./src/second-chunk.js ***! 92 | \*****************************/ 93 | /*! no static exports found */ 94 | /***/ (function(module, exports) { 95 | 96 | console.log('second-chunk'); 97 | 98 | /***/ }) 99 | 100 | /******/ }); 101 | //# sourceMappingURL=second-chunk.bundle.js.map --------------------------------------------------------------------------------