Skip to content

Commit d701904

Browse files
committed
fix: webpack
1 parent 78f052e commit d701904

File tree

16 files changed

+4443
-157
lines changed

16 files changed

+4443
-157
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
Make the vue script setup syntax support the name attribute
66

77
## CHANGELOG
8-
[0.2.4]
8+
[0.2.5]
99
- Fix cjs exports
1010

1111
## CHANGELOG

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "unplugin-vue-setup-extend-plus",
3-
"version": "0.2.4",
3+
"version": "0.2.5",
44
"packageManager": "pnpm@7.1.1",
55
"description": "Extending the vue script setup syntactic sugar",
66
"author": "chenxch <124118265@qq.com>",

playground-webpack/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

playground-webpack/babel.config.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
module.exports = {
2+
presets: [
3+
["@babel/preset-env", {
4+
"targets": {
5+
"browsers": ["last 1 chrome version"]
6+
}
7+
}]
8+
]
9+
}

playground-webpack/index.html

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title><%= htmlWebpackPlugin.options.title %></title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
</body>
11+
</html>

playground-webpack/package.json

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
{
2+
"name": "hand-vue3-project",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"beta": "webpack --config ./webpack.config.js",
8+
"dev": "webpack serve --progress --config ./webpack.config.js"
9+
},
10+
"keywords": [],
11+
"author": "",
12+
"license": "ISC",
13+
"dependencies": {
14+
"unplugin-vue-setup-extend-plus": "0.2.5",
15+
"vue": "^3.0.5"
16+
},
17+
"devDependencies": {
18+
"@babel/core": "^7.12.10",
19+
"@babel/preset-env": "^7.12.11",
20+
"@vue/compiler-sfc": "^3.0.5",
21+
"babel-loader": "^8.2.2",
22+
"clean-webpack-plugin": "^3.0.0",
23+
"css-loader": "^5.0.1",
24+
"html-webpack-plugin": "^4.5.1",
25+
"style-loader": "^2.0.0",
26+
"vue-loader": "^16.1.2",
27+
"webpack": "^5.17.0",
28+
"webpack-cli": "^4.4.0",
29+
"webpack-dev-server": "^3.11.2"
30+
}
31+
}

playground-webpack/src/App.vue

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<script lang="ts" setup name="customApp">
2+
import Comp from './components/comp.vue'
3+
console.log(123)
4+
</script>
5+
6+
<template>
7+
<div>
8+
<div>unplugin-vue-setup-extend-plus</div>
9+
<Comp />
10+
</div>
11+
</template>
12+
13+
<style>
14+
div {
15+
color: yellowgreen;
16+
}
17+
</style>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<script setup name="customCom">
2+
console.log(123)
3+
const data = 'hello'
4+
</script>
5+
6+
<template>
7+
<div>
8+
{{ data }} Comp
9+
</div>
10+
</template>

playground-webpack/src/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { createApp } from 'vue'
2+
import App from './App.vue'
3+
4+
const app = createApp(App)
5+
app.mount('#root')
6+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
const path = require('path')
2+
const HtmlWebpackPlugin = require('html-webpack-plugin')
3+
const { VueLoaderPlugin } = require('vue-loader/dist/index')
4+
const webpack = require('webpack')
5+
const { CleanWebpackPlugin } = require('clean-webpack-plugin')
6+
7+
module.exports = {
8+
mode: 'development',
9+
entry: path.resolve(__dirname, './src/main.js'),
10+
output: {
11+
path: path.resolve(__dirname, 'dist'),
12+
filename: 'js/[name].js'
13+
},
14+
module: {
15+
rules: [
16+
{
17+
test: /\.js$/,
18+
exclude: /node_modules/, // 不编译node_modules下的文件
19+
loader: 'babel-loader'
20+
},
21+
{
22+
test: /\.vue$/,
23+
use: [
24+
'vue-loader'
25+
]
26+
},
27+
{
28+
test: /\.css$/,
29+
use: [
30+
'style-loader',
31+
'css-loader'
32+
]
33+
}
34+
]
35+
},
36+
plugins: [
37+
new HtmlWebpackPlugin({
38+
template: path.resolve(__dirname, './index.html'),
39+
filename: 'index.html',
40+
title: '手搭 Vue 开发环境'
41+
}),
42+
new VueLoaderPlugin(),
43+
new webpack.HotModuleReplacementPlugin(),
44+
new CleanWebpackPlugin(),
45+
require('unplugin-vue-setup-extend-plus/webpack')(),
46+
],
47+
devServer: {
48+
contentBase: path.resolve(__dirname, './dist'),
49+
compress: true,
50+
port: 8080
51+
}
52+
}

0 commit comments

Comments
 (0)