webpack5搭建vue3教-基础篇

webpack5搭建vue3教-基础篇

一.安装vue环境:

1.安装nodejs;

nodejs包含了npm

 

二.安装webpack四件套:

npm install webpack webpack-cli webpack-server webpack-merge -D

 

三.初始化项目:

npm init -y

 

四.配置简单webpack:

1.在根目录下创建webpack.config.js文件

 const path = require('path')

  const resolve = (filePath) => {
      return path.resolve(__dirname, filePath)
  }

  module.exports = env => ({
      mode: env,
      entry: {
          main: resolve('src/main.js')
      },
      output: {
          filename: '/js/[name].js',
          path: resolve('dist')
      }
  })

2.配置package.json

  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "webpack --mode=development"
  },

 

上一篇:webpack5配置解析


下一篇:webpack5的tree shaking值得了解