Skip to content

Commit

Permalink
wip: switched to vite. todo: vite should support css.extract=false
Browse files Browse the repository at this point in the history
  • Loading branch information
fritx committed Aug 11, 2022
1 parent 31cb082 commit 1212f1d
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 61 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ npm i vue1-at # for Vue1 (branch vue1-new)
</template>
<script>
import At from 'vue-at'
import 'vue-at/dist/style.css' // import style
import At from 'vue-at' // import components
export default {
components: { At },
Expand Down Expand Up @@ -90,6 +91,7 @@ With Textarea, `v-model` should be bound in `<textarea>` itself.
</template>
<script>
import 'vue-at/dist/style.css' // import style
// import At from 'vue-at' // for content-editable
import AtTa from 'vue-at/dist/vue-at-textarea' // for textarea
Expand Down
9 changes: 5 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>vue-at</title>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Demo: vue-at</title>
</head>
<body>
<div id="app"></div>
<script src="dist/demo.js"></script>
<script type="module" src="/src/main.js"></script>
</body>
</html>
28 changes: 11 additions & 17 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,19 @@
"author": "Fritz Lin <[email protected]>",
"repository": "https://github.com/fritx/vue-at",
"scripts": {
"lint:fix": "vue-cli-service lint",
"lint": "vue-cli-service lint --no-fix",
"dev:dist": "vue-cli-service serve --skip-plugins eslint",
"dev": "vue-cli-service serve",
"demo": "vue-cli-service build",
"build:at": "vue-cli-service build ./src/At.vue --target lib --name vue-at && shx mv dist/vue-at.common.js dist/vue-at.js",
"build:at-ta": "vue-cli-service build ./src/AtTextarea.vue --target lib --name vue-at-textarea && shx mv dist/vue-at-textarea.common.js dist/vue-at-textarea.js",
"build": "shx rm -rf dist && run-p build:at build:at-ta && shx rm dist/demo.html",
"lint:fix": "eslint --ext .js,.vue --ignore-path .gitignore --fix src",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore src",
"dev": "vite --config vite.demo.config.js",
"demo": "vite build --config vite.demo.config.js",
"build": "shx rm -rf dist && run-s build:at build:at-ta",
"build:at": "vite build --config vite.config.1.js",
"build:at-ta": "vite build --config vite.config.2.js",
"prepublish": "npm run build"
},
"main": "dist/vue-at.js",
"files": [
"dist"
],
"main": "dist/vue-at",
"engines": {
"node": ">= 14.x"
},
Expand All @@ -29,21 +28,16 @@
"vue": "3.x"
},
"devDependencies": {
"@babel/core": "^7.18.9",
"@vue/cli-plugin-eslint": "^5.0.8",
"@vue/cli-service": "^5.0.8",
"@vitejs/plugin-vue": "^3.0.1",
"@vue/compat": "^3.1.0",
"@vue/compiler-sfc": "^3.1.0",
"@vue/eslint-config-standard": "^8.0.1",
"element-plus": "^2.2.12",
"eslint": "^8.21.0",
"eslint-plugin-vue": "^9.3.0",
"npm-run-all": "^4.1.5",
"sass": "^1.53.0",
"sass-loader": "^13.0.2",
"shx": "^0.3.4",
"vue": "^3.1.0",
"vue-loader": "^16.0.0",
"webpack": "^5.73.0"
"vite": "^3.0.5",
"vue": "^3.1.0"
}
}
1 change: 1 addition & 0 deletions public/vite.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 0 additions & 12 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,18 +81,6 @@
import At from './At.vue'
import AtTa from './AtTextarea.vue'
// testing dist
// import At from '../dist/vue-at'
// import AtTa from '../dist/vue-at-textarea'
// testing npm_pack
// import At from '../package/'
// import AtTa from '../package/dist/vue-at-textarea'
// testing node_modules
// import At from 'vue-at'
// import AtTa from 'vue-at/dist/vue-at-textarea'
let members = [
/* eslint-disable */
"Roxie Miles","grace.carroll",
Expand Down
27 changes: 27 additions & 0 deletions vite.config.0.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// https://vueschool.io/articles/vuejs-tutorials/how-to-migrate-from-vue-cli-to-vite/
// vue2
// import { createVuePlugin as vue } from 'vite-plugin-vue2'
// vue3
import vue from '@vitejs/plugin-vue'

// todo: vite should support css.extract=false
// pending https://github.com/vitejs/vite/issues/4345

export default {
plugins: [vue()],
build: {
emptyOutDir: false,
rollupOptions: {
// make sure to externalize deps that shouldn't be bundled
// into your library
external: ['vue'],
output: {
// Provide global variables to use in the UMD build
// for externalized deps
globals: {
vue: 'Vue'
}
}
}
}
}
16 changes: 16 additions & 0 deletions vite.config.1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from 'vite'
import { resolve } from 'path'
import commonConfig from './vite.config.0'

export default defineConfig({
...commonConfig,
build: {
...commonConfig.build,
lib: {
entry: resolve(__dirname, 'src/At.vue'),
name: 'VueAt',
fileName: 'vue-at',
formats: ['cjs', 'umd']
}
}
})
16 changes: 16 additions & 0 deletions vite.config.2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { defineConfig } from 'vite'
import { resolve } from 'path'
import commonConfig from './vite.config.0'

export default defineConfig({
...commonConfig,
build: {
...commonConfig.build,
lib: {
entry: resolve(__dirname, 'src/AtTextarea.vue'),
name: 'VueAtTextarea',
fileName: 'vue-at-textarea',
formats: ['cjs', 'umd']
}
}
})
12 changes: 12 additions & 0 deletions vite.demo.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { defineConfig } from 'vite'

// https://vueschool.io/articles/vuejs-tutorials/how-to-migrate-from-vue-cli-to-vite/
// vue2
// import { createVuePlugin as vue } from 'vite-plugin-vue2'
// vue3
import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()]
})
27 changes: 0 additions & 27 deletions vue.config.js

This file was deleted.

0 comments on commit 1212f1d

Please sign in to comment.