第一种:

  没有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"
  }
}

 

)

相关文章:

  • 2021-11-27
  • 2022-01-10
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
猜你喜欢
  • 2021-07-08
  • 2021-09-05
  • 2022-01-14
  • 2022-12-23
  • 2021-10-12
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案