Skip to content

Commit

Permalink
feat: 0.4.6
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxch committed Jan 20, 2023
1 parent ae58b76 commit d1e1d9f
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 37 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

[0.4.6]
- Fix: webpack parsing failed resulting in process termination[#12](https://github.com/chenxch/unplugin-vue-setup-extend-plus/issues/12)

[0.4.5]
- Fix: commonjs

Expand Down
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ Make the vue script setup syntax support the name attribute

## CHANGELOG

[0.4.6]
- Fix: webpack parsing failed resulting in process termination[#12](https://github.com/chenxch/unplugin-vue-setup-extend-plus/issues/12)

[0.4.5]
- Fix: commonjs

Expand All @@ -19,12 +22,6 @@ Make the vue script setup syntax support the name attribute
- Fix: use more specific function types[#6](https://github.com/chenxch/unplugin-vue-setup-extend-plus/issues/6)
- Remove `fileName` mode (Because its performance is consistent with the performance of Vue itself, it is a repetitive thing.)

[0.3.1]
- Fix legacy node `replaceAll`[#5](https://github.com/chenxch/unplugin-vue-setup-extend-plus/issues/5)

[0.3.0]
- Feature[#4](https://github.com/chenxch/unplugin-vue-setup-extend-plus/issues/4)
- Expanded the function of automatic name generation
`For details, refer to Options and extendIgnore`

## Feature
Expand Down
14 changes: 7 additions & 7 deletions playground-webpack/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
module.exports = {
presets: [
["@babel/preset-env", {
"targets": {
"browsers": ["last 1 chrome version"]
}
}]
]
}
['@babel/preset-env', {
targets: {
browsers: ['last 1 chrome version'],
},
}],
],
}
2 changes: 1 addition & 1 deletion playground-webpack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"author": "",
"license": "ISC",
"dependencies": {
"unplugin-vue-setup-extend-plus": "workspace:^0.3.1",
"unplugin-vue-setup-extend-plus": "workspace:^0.4.5",
"vue": "^3.0.5"
},
"devDependencies": {
Expand Down
28 changes: 14 additions & 14 deletions playground-webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,50 +3,50 @@ const HtmlWebpackPlugin = require('html-webpack-plugin')
const { VueLoaderPlugin } = require('vue-loader/dist/index')
const webpack = require('webpack')
const { CleanWebpackPlugin } = require('clean-webpack-plugin')

console.log(require('unplugin-vue-setup-extend-plus/webpack'))
module.exports = {
mode: 'development',
entry: path.resolve(__dirname, './src/main.js'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'js/[name].js'
filename: 'js/[name].js',
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/, // 不编译node_modules下的文件
loader: 'babel-loader'
loader: 'babel-loader',
},
{
test: /\.vue$/,
use: [
'vue-loader'
]
'vue-loader',
],
},
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
}
]
'css-loader',
],
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: path.resolve(__dirname, './index.html'),
filename: 'index.html',
title: '手搭 Vue 开发环境'
title: '手搭 Vue 开发环境',
}),
new VueLoaderPlugin(),
new webpack.HotModuleReplacementPlugin(),
new CleanWebpackPlugin(),
require('unplugin-vue-setup-extend-plus/webpack')(),
require('unplugin-vue-setup-extend-plus/webpack').default(),
],
devServer: {
contentBase: path.resolve(__dirname, './dist'),
compress: true,
port: 8080
}
}
port: 8080,
},
}
2 changes: 1 addition & 1 deletion playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"devDependencies": {
"@vitejs/plugin-vue": "^2.3.3",
"typescript": "^4.6.4",
"unplugin-vue-setup-extend-plus": "workspace:^0.3.1",
"unplugin-vue-setup-extend-plus": "workspace:^0.4.5",
"vite": "^4.0.0",
"vite-plugin-inspect": "^0.5.0"
},
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 13 additions & 5 deletions src/core/unplugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createUnplugin } from 'unplugin'
import type { Options } from '../types'
import { supportScriptName } from './transform'

export default createUnplugin((options: Options = {}) => {
export default createUnplugin((options: Options = {}, meta) => {
return {
name: 'unplugin-vue-setup-extend-plus',
enforce: 'pre',
Expand All @@ -12,11 +12,19 @@ export default createUnplugin((options: Options = {}) => {
},

async transform(code, id) {
if (options.mode && options.mode === 'none')
try {
if (options.mode && options.mode === 'none')
return null
if (/\.vue$/.test(id) || /\.vue\?.*type=script.*/.test(id))
return supportScriptName.call(this, code, id, options)
return null
if (/\.vue$/.test(id) || /\.vue\?.*type=script.*/.test(id))
return supportScriptName.call(this, code, id, options)
return null
}
catch (e) {
if (meta.framework === 'webpack') {
console.error(e)
return null
}
}
},
}
})

0 comments on commit d1e1d9f

Please sign in to comment.