Skip to content

Commit 1466f42

Browse files
committed
v1.0.0
0 parents  commit 1466f42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+34586
-0
lines changed

.babelrc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"presets": [
3+
"@vue/cli-plugin-babel/preset"
4+
]
5+
}

.env.dev

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NODE_ENV = development
2+
3+
VUE_APP_ENV = development

.env.doc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
VUE_APP_ENV = doc

.env.iframe

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NODE_ENV = production
2+
3+
VUE_APP_ENV = iframe

.env.pro

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
NODE_ENV = production
2+
3+
VUE_APP_ENV = production

.eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
lib
2+
dist
3+
file-viewer
4+
vendors

.eslintrc.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* @Author: zhanghan
3+
* @Date: 2023-01-04 13:49:25
4+
* @LastEditors: zhanghan
5+
* @LastEditTime: 2023-01-10 00:16:51
6+
* @Descripttion:
7+
*/
8+
module.exports = {
9+
root: true,
10+
env: {
11+
node: true
12+
},
13+
extends: ['plugin:vue/essential', 'eslint:recommended'],
14+
parserOptions: {
15+
parser: '@babel/eslint-parser'
16+
},
17+
rules: {
18+
'no-console': 'off',
19+
'no-debugger': 'off',
20+
'no-unused-vars': ['error', { args: 'none' }], // 允许函数参数未使用
21+
'no-control-regex': 0, // 允许在正则表达式中使用控制字符
22+
//关闭组件命名规则
23+
'vue/multi-word-component-names': 'off',
24+
// 强制使用单引号
25+
quotes: ['error', 'single'],
26+
// 强制不使用分号结尾
27+
semi: ['error', 'never']
28+
}
29+
}

.gitignore

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
.DS_Store
2+
node_modules
3+
/dist
4+
/lib
5+
/docdist
6+
.cache
7+
.temp
8+
doc/.vuepress/dist/
9+
10+
# local env files
11+
.env.local
12+
.env.*.local
13+
14+
# Log files
15+
npm-debug.log*
16+
yarn-debug.log*
17+
yarn-error.log*
18+
pnpm-debug.log*
19+
20+
# Editor directories and files
21+
.idea
22+
.vscode
23+
*.suo
24+
*.ntvs*
25+
*.njsproj
26+
*.sln
27+
*.sw?

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
shamefully-hoist=true

README.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# vue-file-viewer
2+
3+
### 安装
4+
5+
```
6+
yarn install
7+
```
8+
9+
### 启动本地演示调试
10+
11+
```
12+
yarn run serve
13+
```
14+
15+
### 打包成 npm 组件
16+
17+
```
18+
yarn run build
19+
```
20+
21+
### 打包项目提供 iframe 入口使用
22+
23+
```
24+
yarn run build:iframe
25+
```

babel.config.js

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* @Author: zhanghan
3+
* @Date: 2022-11-27 19:21:21
4+
* @LastEditors: zhanghan
5+
* @LastEditTime: 2022-11-28 20:19:04
6+
* @Descripttion: babe配置
7+
*/
8+
module.exports = {
9+
presets: ['@vue/cli-plugin-babel/preset']
10+
}

config/config.build.iframe.js

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* @Author: zhanghan
3+
* @Date: 2022-11-28 09:13:53
4+
* @LastEditors: zhanghan
5+
* @LastEditTime: 2023-01-10 15:07:37
6+
* @Descripttion: iframe开发环境配置
7+
*/
8+
const path = require('path')
9+
// 获取当前工作目录
10+
const cwd = process.cwd()
11+
12+
module.exports = {
13+
publicPath: '/file-viewer',
14+
// 放在public下供项目演示时作为iframe入口使用
15+
outputDir: path.join(cwd, '/public/file-viewer'),
16+
pages: {
17+
index: {
18+
entry: 'examples/main.js',
19+
template: 'public/index.html',
20+
filename: 'index.html'
21+
}
22+
},
23+
assetsDir: 'static',
24+
// 扩展 webpack 配置
25+
chainWebpack: (config) => {
26+
// set worker-loader
27+
config.module
28+
.rule('worker')
29+
.test(/\.worker\.js$/)
30+
.use('worker-loader')
31+
.loader('worker-loader')
32+
.end()
33+
34+
// 解决:worker 热更新问题
35+
config.module.rule('js').exclude.add(/\.worker\.js$/)
36+
37+
// packages 加入编译
38+
config.module
39+
.rule('js')
40+
.include.add('/packages')
41+
.end()
42+
.use('babel')
43+
.loader('babel-loader')
44+
45+
// 别名配置
46+
config.resolve.alias.set('@', '/examples').set('@packages', '/packages')
47+
}
48+
}

config/config.build.js

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* @Author: zhanghan
3+
* @Date: 2022-11-28 09:13:53
4+
* @LastEditors: zhanghan
5+
* @LastEditTime: 2023-01-09 21:49:06
6+
* @Descripttion: 生产环境配置
7+
*/
8+
9+
const path = require('path')
10+
// 获取基于当前路径的目标文件
11+
const resolve = (dir) => path.join(__dirname, '../', dir)
12+
13+
const buildConfig = {
14+
// 输出文件目录
15+
outputDir: resolve('lib'),
16+
productionSourceMap: false,
17+
// webpack配置
18+
configureWebpack: {
19+
// 入口文件(这里获取到的是每个独立包的入口文件地址数组)
20+
entry: {
21+
// 全量引入的文件入口
22+
index: resolve('packages')
23+
},
24+
// 输出配置
25+
output: {
26+
// 主入口文件名称
27+
filename: '[name]/index.js',
28+
// 构建依赖类型
29+
libraryTarget: 'umd',
30+
// 库中被导出的项
31+
libraryExport: 'default',
32+
// 引用时的依赖名
33+
library: 'vue-file-viewer'
34+
}
35+
},
36+
css: {
37+
sourceMap: false,
38+
// 是否将组件中的css提取至一个独立的css,库构建时可以设置为false,免得用户需要自己导入css
39+
extract: false
40+
// extract: {
41+
// filename: '[name]/index.css',
42+
// },
43+
},
44+
chainWebpack: (config) => {
45+
// set worker-loader
46+
config.module
47+
.rule('worker')
48+
.test(/\.worker\.js$/)
49+
.use('worker-loader')
50+
.loader('worker-loader')
51+
.end()
52+
53+
// 解决:worker 热更新问题
54+
config.module.rule('js').exclude.add(/\.worker\.js$/)
55+
56+
// 一些构建优化
57+
// 删除splitChunks,因为每个组件是独立打包,不需要抽离每个组件的公共js出来。
58+
config.optimization.delete('splitChunks')
59+
// 删除copy,不要复制public文件夹内容到lib文件夹中。
60+
config.plugins.delete('copy')
61+
// 删除preload以及prefetch,因为不生成html页面,所以这两个也没用。
62+
config.plugins.delete('preload')
63+
config.plugins.delete('prefetch')
64+
// 删除html,只打包组件,不生成html页面。
65+
config.plugins.delete('html')
66+
// 删除hmr,删除热更新。
67+
config.plugins.delete('hmr')
68+
// 删除自动加上的入口App。
69+
config.entryPoints.delete('app')
70+
}
71+
}
72+
73+
module.exports = buildConfig

config/config.dev.js

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* @Author: zhanghan
3+
* @Date: 2022-11-28 09:13:53
4+
* @LastEditors: zhanghan
5+
* @LastEditTime: 2023-01-09 23:53:58
6+
* @Descripttion: 开发环境配置
7+
*/
8+
9+
module.exports = {
10+
pages: {
11+
index: {
12+
entry: 'examples/main.js',
13+
template: 'public/index.html',
14+
filename: 'index.html'
15+
}
16+
},
17+
// 扩展 webpack 配置
18+
chainWebpack: (config) => {
19+
// set worker-loader
20+
config.module
21+
.rule('worker')
22+
.test(/\.worker\.js$/)
23+
.use('worker-loader')
24+
.loader('worker-loader')
25+
.end()
26+
27+
// 解决:worker 热更新问题
28+
config.module.rule('js').exclude.add(/\.worker\.js$/)
29+
30+
// packages 加入编译
31+
config.module
32+
.rule('js')
33+
.include.add('/packages')
34+
.end()
35+
.use('babel')
36+
.loader('babel-loader')
37+
38+
// 别名配置
39+
config.resolve.alias.set('@', '/examples').set('@packages', '/packages')
40+
}
41+
}

config/config.doc.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* @Author: zhanghan
3+
* @Date: 2022-11-28 09:13:53
4+
* @LastEditors: zhanghan
5+
* @LastEditTime: 2023-01-10 15:44:37
6+
* @Descripttion: 文档环境配置
7+
*/
8+
9+
module.exports = {
10+
outputDir: './doc-dist',
11+
publicPath: '/file-viewer-doc',
12+
assetsDir: 'static',
13+
pages: {
14+
index: {
15+
entry: 'doc/main.js',
16+
template: 'public/index.html',
17+
filename: 'index.html'
18+
}
19+
},
20+
// 扩展 webpack 配置
21+
chainWebpack: (config) => {
22+
// set worker-loader
23+
config.module
24+
.rule('worker')
25+
.test(/\.worker\.js$/)
26+
.use('worker-loader')
27+
.loader('worker-loader')
28+
.end()
29+
30+
// 解决:worker 热更新问题
31+
config.module.rule('js').exclude.add(/\.worker\.js$/)
32+
33+
// packages 加入编译
34+
config.module
35+
.rule('js')
36+
.include.add('/packages')
37+
.end()
38+
.use('babel')
39+
.loader('babel-loader')
40+
41+
// 别名配置
42+
config.resolve.alias.set('@', '/doc').set('@packages', '/packages')
43+
},
44+
css: {
45+
loaderOptions: {
46+
sass: {
47+
data: '@import "~@/style/imports.scss";'
48+
}
49+
}
50+
}
51+
}

0 commit comments

Comments
 (0)