webpack 基本使用
2018-01-21 20:26
537 查看
1. 创建webpack-test文件夹
2. npm初始化
3. 安装webpack
4. 使用webpack打包
hello.js 是需要打包的文件 hello.bundle.js 是打包完以后文件的名称
hello.js文件
hello.bundle.js文件
5. 完整的例子
5.1 创建tom.js
5.2 创建main.css
5.3 在hello.js是引用css和js
5.4 创建index.html 并引用 hello.bundle.js
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
相关文章推荐
- webpack的基本使用
- webpack使用优化(基本篇)
- webpack的基本使用(一)
- 【23】使用vue-cli脚手架搭建webpack项目基本结构
- windows下安装nodejs 、webpack及vue.js的基本使用<一>
- webpack学习之一,基本使用和管理资源
- webpack2.0 基本使用
- 项目中使用webpack基本的配置
- vue实战--webpack基本使用
- webpack基本使用
- 二九、webpack基本使用流程
- webpack的基本使用(二)
- webpack使用优化(基本篇)
- vue.js基本使用 利用webpack"热"运行vuejs+html初步和关键步骤 <二>
- vue实战--webpack基本使用二
- webpack基本使用
- [Android API 学习]WebView基本使用
- tomcat 使用及基本发布web
- 极客技术专题【004期】:Web开发人员的必备工具 - Emmet (Zen Coding)基本使用
- WebView基本使用