zoukankan      html  css  js  c++  java
  • webpack基础理解以及使用搭建

    1.webpack 是一个前端资源加载/打包工具,前端的常用资源都可以作为一个模板导出,我们在代码中直接引用即可,最后把我们的代码打包整合起来。

    前端资源,包括(js,css,图片,模块)等。

    下面是一个webpack的配置说明:

     1  module.exports ={  // webpack配置说明
     2    entry:'./entry.js',  // 入口文件
     3   output:{  //  告诉webpack,生成的文件放在什么地方
     4       path:'./dist',  //  文件夹位置
     5      filename:'bundle.js'  //  文件名
     6    },
     7    module:{
     8      loaders:[  // 进行对css导入 ,jsx是react的语法
     9        {  test:/.css$/,loader:"style!css"}
    10        {  test:/.js|jsx$/,loaders:['babel']}
    11      ] 
    12    }
    13  }

    判断是不是安装了node.js

    node.js官方网址:http://nodejs.org/ 

    输入 npm init 

    E:
    eact-music-player>npm init
    This utility will walk you through creating a package.json file.
    It only covers the most common items, and tries to guess sensible defaults.
    
    See `npm help json` for definitive documentation on these fields
    and exactly what they do.
    
    Use `npm install <pkg> --save` afterwards to install a package and
    save it as a dependency in the package.json file.
    
    Press ^C at any time to quit.
    name: (react-music-player)  //名字敲回车
    version: (1.0.0)
    description: music player build
    entry point: (index.js)  //输入文件
    entry point: (index.js) app/index.js
    test command:  //测试案例
    git repository:  //是否放在git上git地址
    keywords: webpack react music-player
    author: estelle
    license: (ISC) MIT

    About to write to E: eact-music-playerpackage.json:

    {
    "name": "react-music-player",
    "version": "1.0.0",
    "description": "music player build",
    "main": "app/index.js",
    "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
    },
    "keywords": [
    "webpack",
    "react",
    "music-player"
    ],
    "author": "estelle",
    "license": "MIT"
    }

    Is this ok? (yes) yes

     增加依赖模块,比如依赖于react :npm install react --save

  • 相关阅读:
    LOJ #2109. 「JLOI2015」骗我呢 数形结合+组合+容斥
    LOJ #2729. 「JOISC 2016 Day 1」俄罗斯套娃 扫描线+贪心
    LOJ #2508. 「AHOI / HNOI2018」游戏 拓扑排序
    LOJ #2106. 「JLOI2015」有意义的字符串 构造+矩阵乘法
    LOJ #2471. 「九省联考 2018」一双木棋 记忆化搜索
    python的md5和base64加密
    [转]python的find()方法
    [转]python的startswith()方法
    获取http请求的响应状态
    with...as...用法
  • 原文地址:https://www.cnblogs.com/Lolita-web/p/webpack.html
Copyright © 2011-2022 走看看