Skip to content

Commit 887cdaa

Browse files
committed
Optimize build
1 parent e5086e4 commit 887cdaa

15 files changed

+5888
-1364
lines changed

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Vue.use(VueClock);
3434
```vue
3535
<template>
3636
<div class="app">
37-
<vue-clock />
37+
<VueClock />
3838
</div>
3939
</template>
4040
@@ -52,7 +52,6 @@ export default {
5252
```javascript
5353
import Vue from 'vue';
5454
import VueClock from '@dangvanthanh/vue-clock';
55-
import 'vue-clock/dist/vue-clock.esm.css';
5655

5756
Vue.component('VueClock', VueClock);
5857
// or

build/rollup.config.base.js

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

build/rollup.config.browsers.js

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

build/rollup.config.cjs.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { pascalCase } from 'pascal-case'
2+
import replace from '@rollup/plugin-replace'
3+
import { nodeResolve } from '@rollup/plugin-node-resolve'
4+
import commonjs from '@rollup/plugin-commonjs'
5+
import vue from 'rollup-plugin-vue'
6+
import filesize from 'rollup-plugin-filesize'
7+
import pkg from '../package.json'
8+
9+
const globals = {
10+
// Provide global variable names to replace your external imports
11+
// eg. jquery: '$'
12+
vue: 'Vue',
13+
}
14+
15+
const config = {
16+
input: 'src/index.js',
17+
output: {
18+
compact: true,
19+
name: pascalCase(pkg.name),
20+
file: pkg.main,
21+
format: 'cjs',
22+
exports: 'named',
23+
globals,
24+
},
25+
plugins: [
26+
replace({
27+
'process.env.NODE_ENV': JSON.stringify('production'),
28+
'process.env.ES_BUILD': JSON.stringify('false'),
29+
}),
30+
nodeResolve(),
31+
commonjs(),
32+
vue({ css: true, template: { optimizeSSR: true } }),
33+
filesize(),
34+
],
35+
}
36+
37+
export default config

build/rollup.config.es.js

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,28 @@
1-
import { writeFileSync } from 'fs';
2-
import vue from 'rollup-plugin-vue';
3-
import css from 'rollup-plugin-css-only';
4-
import filesize from 'rollup-plugin-filesize';
5-
import CleanCSS from 'clean-css';
6-
import base from './rollup.config.base';
7-
import pkg from '../package.json';
1+
import replace from '@rollup/plugin-replace'
2+
import { nodeResolve } from '@rollup/plugin-node-resolve'
3+
import commonjs from '@rollup/plugin-commonjs'
4+
import vue from 'rollup-plugin-vue'
5+
import filesize from 'rollup-plugin-filesize'
6+
import pkg from '../package.json'
87

9-
const config = Object.assign({}, base, {
8+
const config = {
9+
input: 'src/index.js',
1010
output: {
11-
name: 'vue-clock',
11+
name: pkg.name,
1212
file: pkg.module,
13-
format: 'es',
13+
format: 'esm',
14+
exports: 'named',
1415
},
15-
});
16+
plugins: [
17+
replace({
18+
'process.env.NODE_ENV': JSON.stringify('production'),
19+
'process.env.ES_BUILD': JSON.stringify('true'),
20+
}),
21+
nodeResolve(),
22+
commonjs(),
23+
vue({ css: true }),
24+
filesize(),
25+
],
26+
}
1627

17-
config.plugins.push(vue({ template: { optimizeSSR: true }, css: false }));
18-
config.plugins.push(
19-
css({
20-
output: function(styles) {
21-
writeFileSync(
22-
'dist/vue-clock.esm.css',
23-
new CleanCSS().minify(styles).styles
24-
);
25-
},
26-
})
27-
);
28-
config.plugins.push(filesize());
29-
30-
export default config;
28+
export default config

build/rollup.config.umd.js

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

build/rollup.config.unpkg.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { pascalCase } from 'pascal-case'
2+
import replace from '@rollup/plugin-replace'
3+
import { nodeResolve } from '@rollup/plugin-node-resolve'
4+
import commonjs from '@rollup/plugin-commonjs'
5+
import vue from 'rollup-plugin-vue'
6+
import filesize from 'rollup-plugin-filesize'
7+
import pkg from '../package.json'
8+
9+
const globals = {
10+
// Provide global variable names to replace your external imports
11+
// eg. jquery: '$'
12+
vue: 'Vue',
13+
}
14+
15+
const config = {
16+
input: 'src/index.js',
17+
output: {
18+
compact: true,
19+
name: pascalCase(pkg.name),
20+
file: pkg.unpkg,
21+
format: 'iife',
22+
exports: 'named',
23+
globals,
24+
},
25+
plugins: [
26+
replace({
27+
'process.env.NODE_ENV': JSON.stringify('production'),
28+
'process.env.ES_BUILD': JSON.stringify('false'),
29+
}),
30+
nodeResolve(),
31+
commonjs(),
32+
vue({ css: true }),
33+
filesize(),
34+
],
35+
}
36+
37+
export default config

0 commit comments

Comments
 (0)