Skip to content

Instantly share code, notes, and snippets.

@atsuya046
Last active November 5, 2015 20:09
Show Gist options
  • Save atsuya046/c3b1f53cc847fa49f1fc to your computer and use it in GitHub Desktop.
Save atsuya046/c3b1f53cc847fa49f1fc to your computer and use it in GitHub Desktop.
test_webpack

Install webpack

npm install webpack -g

Build

webpack ./main.js bundle.js
/******/ (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__) {
(function(){
var G = __webpack_require__(1);
var greeter = new G();
greeter.exec();
})();
/***/ },
/* 1 */
/***/ function(module, exports) {
function Greeter() {
this.greet = "Hello world";
this.exec = function() {
console.log(this.greet);
};
}
module.exports = Greeter;
/***/ }
/******/ ]);
function Greeter() {
this.greet = "Hello world";
this.exec = function() {
console.log(this.greet);
};
}
module.exports = Greeter;
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<script type="text/javascript" src="bundle.js" charset="utf-8"></script>
</body>
</html>
(function(){
var G = require('./greeter.js');
var greeter = new G();
greeter.exec();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment