乐趣区

webpack05Output输出配置

https://www.webpackjs.com/con…

cnpm init -y

cnpm i -D webpack webpack-cli

配置文件 webpack.config.js

const path=require('path')
module.exports={
    entry:{
        test:'./src/index.js',
        demo:'./src/main.js'
    },
    mode:'development',
    output:{
        //hash 指定 6 位
        filename:'[name]_[hash:6]_bundle.js',
        path:path.join(__dirname,'lib'),
        // 生成文件:test_6ae182_bundle.js demo_6ae182_bundle.js,
        /*
静态资源准备放到 cdn 时候,需要加上前缀,就用 publicPath
        */
        //publicPath:'http://cdn.baidu.com/assets'
    }
}

配置文件 package.json

{
  "name": "05",
  "version": "1.0.0",
  "description": "","main":"index.js","scripts": {"build":"webpack --config webpack.config.js"},"keywords": [],"author":"",
  "license": "ISC",
  "devDependencies": {
    "webpack": "^4.43.0",
    "webpack-cli": "^3.3.11"
  }
}

未完待续 …

退出移动版