Skip to content

Commit 52e4402

Browse files
committed
rea: Support Tree Shaking
1 parent 3589436 commit 52e4402

Some content is hidden

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

63 files changed

+3360
-2875
lines changed

.browserslistrc

Lines changed: 0 additions & 3 deletions
This file was deleted.

.eslintignore

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

.eslintrc.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module.exports = {
2+
root: true,
3+
env: {
4+
node: true,
5+
},
6+
extends: [
7+
'plugin:vue/vue3-essential',
8+
'@vue/airbnb',
9+
],
10+
parserOptions: {
11+
},
12+
rules: {
13+
'consistent-return': 0,
14+
'vue/no-side-effects-in-computed-properties': 0,
15+
'no-restricted-globals': 0,
16+
'no-unused-vars': 0,
17+
'no-plusplus': 0,
18+
'no-multi-assign': 0,
19+
'no-use-before-define': 0,
20+
'no-underscore-dangle': 0,
21+
'no-mixed-operators': 0,
22+
'no-unused-expressions': 0,
23+
'max-len': 0,
24+
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
25+
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
26+
'import/no-extraneous-dependencies': 0,
27+
},
28+
};

.gitignore

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
node_modules
2-
coverage
3-
lib
4-
dist
5-
docs
1+
node_modules/
2+
dist/
3+
libs/
4+
website/
5+

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit "$1"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# [1.0.0] - 2021-08-26
2+
3+
## Feature
4+
Now we can import on Demand (Tree Shaking)

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ new Vue({
4343
},
4444
});
4545
```
46+
47+
## [CHANGELOG](/CHANGELOG.md)
4648
## License
4749

4850
vue-color is licensed under [The MIT License](LICENSE).

babel.config.js

Lines changed: 0 additions & 16 deletions
This file was deleted.

build/build.config.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
import path from 'path';
2+
3+
import resolve from '@rollup/plugin-node-resolve';
4+
import alias from '@rollup/plugin-alias';
5+
import vue from 'rollup-plugin-vue';
6+
import { terser } from 'rollup-plugin-terser';
7+
import postcss from 'rollup-plugin-postcss';
8+
import commonjs from '@rollup/plugin-commonjs';
9+
10+
import prefixer from 'postcss-prefixer';
11+
12+
import { name, cssPrefix } from '../src/defaultConfig';
13+
14+
const projectRoot = path.resolve(__dirname, '../src');
15+
const globals = {
16+
// Provide global variable names to replace your external imports, eg. jquery: '$'
17+
vue: 'Vue',
18+
};
19+
20+
const postcssPlugin = (options = {}) => {
21+
const minimize = options.minimize !== false;
22+
const exclude = options.exclude || /node_modules/;
23+
const include = options.include || /(?<!&module=.*)\.css$/;
24+
return postcss({
25+
minimize,
26+
plugins: [prefixer({
27+
prefix: cssPrefix,
28+
})],
29+
exclude,
30+
include,
31+
extract: options.extract,
32+
});
33+
};
34+
35+
const plugins = {
36+
alias: alias({
37+
entries: [
38+
{
39+
find: '@',
40+
replacement: projectRoot,
41+
},
42+
],
43+
}),
44+
resolve: resolve(),
45+
terser: terser(),
46+
vue: vue({
47+
include: /\.vue$/,
48+
target: 'browser',
49+
css: false,
50+
exposeFilename: false,
51+
preprocessStyles: false,
52+
cssModulesOptions: {
53+
generateScopedName: '[local]___[hash:base64:5]',
54+
},
55+
}),
56+
postcss: postcssPlugin,
57+
commonjs: commonjs(),
58+
};
59+
60+
const output = {
61+
name,
62+
globals,
63+
};
64+
65+
const external = ['vue'];
66+
67+
export {
68+
projectRoot,
69+
plugins,
70+
output,
71+
external,
72+
};

0 commit comments

Comments
 (0)