- yarn add vue
- yarn add webpack
- yarn add webpack-cli
- yarn add html-webpack-plugin
- yarn add webpack-dev-server
- 创建build、src文件夹
- 创建index.html文件
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Vue</title> </head> <body> <div id="app"></div> </body> </html>
- 创建src/index.js文件
import Vue from ‘vue‘ new Vue({ el:‘#app‘, render(h){ return h(‘div‘,‘hello world!‘) } })
- 创建build/webpack.dev.conf.js文件
const HtmlWebpackPlugin = require(‘html-webpack-plugin‘) module.exports = { entry: ‘./src/index‘, output: { filename:‘./dist/main.js‘ }, plugins:[new HtmlWebpackPlugin({ filename:‘index.html‘, template:‘./src/index.html‘, inject:true //true夹在在文件尾部 })], devServer: { port:1222, open:true//自动打开浏览器 } }
- 在package.json中添加scripts
- yarn start 启动项目
.github a { text-decoration: none; color: #3787ff; line-height: 20px }
.github { margin-left: 20px }
ol { padding-left: 15px !important }
原文地址:https://www.cnblogs.com/hanxiaoer/p/9550210.html
时间: 2024-11-03 21:19:23