• 微信公众号:美女很有趣。 工作之余,放松一下,关注即送10G+美女照片!

webpack5搭建vue3教-基础篇

开发技术 开发技术 4小时前 2次浏览

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搭建vue3教-基础篇
喜欢 (0)