Skip to content

Instantly share code, notes, and snippets.

@justin808
Created July 17, 2015 08:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justin808/d9a7c0f6c5721c325854 to your computer and use it in GitHub Desktop.
Save justin808/d9a7c0f6c5721c325854 to your computer and use it in GitHub Desktop.
Simplest Hello World Webpack output with global export
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/***/ function(module, exports, __webpack_require__) {
__webpack_require__(1);
module.exports = __webpack_require__(3);
/***/ },
/* 1 */
/***/ function(module, exports, __webpack_require__) {
// Make sure the following files are
//import HelloWorld from './HelloWorld';
'use strict';
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
var _HelloString = __webpack_require__(2);
//import React from 'react';
var _HelloString2 = _interopRequireDefault(_HelloString);
/***/ },
/* 2 */
/***/ function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var HelloString = {
world: function world() {
return "Hello WORLD! Will this work??";
}
};
//global.HelloString = HelloString;
exports["default"] = HelloString;
module.exports = exports["default"];
/***/ },
/* 3 */
/***/ function(module, exports) {
/* WEBPACK VAR INJECTION */(function(__dirname) {//const path = require('path');
"use strict";
module.exports = {
context: __dirname,
entry: ["Global"],
output: {
path: "../app/assets/javascripts/generated",
filename: "bundle.js"
},
resolve: {
root: [path.join(__dirname, "js")],
extensions: ["", ".js", ".jsx"]
},
module: {
loaders: [{ loader: "babel-loader" }, { test: "HelloString", loader: "expose?HelloString" }]
}
};
/* WEBPACK VAR INJECTION */}.call(exports, "/"))
/***/ }
/******/ ]);
@justin808
Copy link
Author

Example of WEBPACK VAR INJECTION

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment