zoukankan      html  css  js  c++  java
  • webpack 基本使用

    1. 创建webpack-test文件夹

    2. npm初始化

    3. 安装webpack

    4. 使用webpack打包  

     hello.js 是需要打包的文件  hello.bundle.js 是打包完以后文件的名称

    hello.js文件

     hello.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] = {
    /******/ 			i: moduleId,
    /******/ 			l: false,
    /******/ 			exports: {}
    /******/ 		};
    /******/
    /******/ 		// Execute the module function
    /******/ 		modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
    /******/
    /******/ 		// Flag the module as loaded
    /******/ 		module.l = 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;
    /******/
    /******/ 	// define getter function for harmony exports
    /******/ 	__webpack_require__.d = function(exports, name, getter) {
    /******/ 		if(!__webpack_require__.o(exports, name)) {
    /******/ 			Object.defineProperty(exports, name, {
    /******/ 				configurable: false,
    /******/ 				enumerable: true,
    /******/ 				get: getter
    /******/ 			});
    /******/ 		}
    /******/ 	};
    /******/
    /******/ 	// getDefaultExport function for compatibility with non-harmony modules
    /******/ 	__webpack_require__.n = function(module) {
    /******/ 		var getter = module && module.__esModule ?
    /******/ 			function getDefault() { return module['default']; } :
    /******/ 			function getModuleExports() { return module; };
    /******/ 		__webpack_require__.d(getter, 'a', getter);
    /******/ 		return getter;
    /******/ 	};
    /******/
    /******/ 	// Object.prototype.hasOwnProperty.call
    /******/ 	__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
    /******/
    /******/ 	// __webpack_public_path__
    /******/ 	__webpack_require__.p = "";
    /******/
    /******/ 	// Load entry module and return exports
    /******/ 	return __webpack_require__(__webpack_require__.s = 0);
    /******/ })
    /************************************************************************/
    /******/ ([
    /* 0 */
    /***/ (function(module, exports) {
    
    function  hello(str) {
        alert(str);
    }
    
    /***/ })
    /******/ ]);
    

      

     5. 完整的例子

    5.1 创建tom.js

    5.2 创建main.css

    5.3 在hello.js是引用css和js

    5.4 创建index.html 并引用 hello.bundle.js

  • 相关阅读:
    sdk 今日头条_字节跳动又一Android开源力作!全新视频动画特效SDK
    Android播放透明视频(转载)
    git remote: warning: suboptimal pack
    'gitclone报错fatal:protocolerror:badpackheader'
    解决 Maven 无法下载 fastdfs-client-java 依赖。
    教我兄弟学Android逆向12 编写xposed模块
    教我兄弟学Android逆向11 动态调试init_array
    CommunicationsException
    使用css给table表格表头添加斜线(斜线表格)
    [SAA + SAP] 28. Monitoring
  • 原文地址:https://www.cnblogs.com/linlf03/p/8325312.html
Copyright © 2011-2022 走看看