webpack的三種運行方式


第一種:

  沒有webpack.cofig.js文件使用默認配置文件的時候 在命令行輸入 npx  webpack  index.js (接口文件為index.js)

第二種:

  有webpack.cofig.js文件  在命令行輸入npx  webpack

const path = require('path');
module.exports = {
    entry:'./src/index.js',
    output:{
        //生成的接口文件 
        filename:'bundle.js',
        //生成的bundle.js文件放置在dist文件中
        path:path.resolve(__dirname,'dist')
    }
}

 第三種:

   有webpack.cofig.js文件  在命令行輸入npx  run bundle(需要將package.json更改

{
  "name": "webpackcase",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "scripts": {
    "bundle": "webpack"//更改的部分
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "webpack": "^4.37.0",
    "webpack-cli": "^3.3.6"
  }
}

 

)


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM