Skip to content

Commit

Permalink
Optimize build
Browse files Browse the repository at this point in the history
  • Loading branch information
dangvanthanh committed Dec 15, 2020
1 parent e5086e4 commit 887cdaa
Show file tree
Hide file tree
Showing 15 changed files with 5,888 additions and 1,364 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Vue.use(VueClock);
```vue
<template>
<div class="app">
<vue-clock />
<VueClock />
</div>
</template>
Expand All @@ -52,7 +52,6 @@ export default {
```javascript
import Vue from 'vue';
import VueClock from '@dangvanthanh/vue-clock';
import 'vue-clock/dist/vue-clock.esm.css';

Vue.component('VueClock', VueClock);
// or
Expand Down
7 changes: 0 additions & 7 deletions build/rollup.config.base.js

This file was deleted.

20 changes: 0 additions & 20 deletions build/rollup.config.browsers.js

This file was deleted.

37 changes: 37 additions & 0 deletions build/rollup.config.cjs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { pascalCase } from 'pascal-case'
import replace from '@rollup/plugin-replace'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import vue from 'rollup-plugin-vue'
import filesize from 'rollup-plugin-filesize'
import pkg from '../package.json'

const globals = {
// Provide global variable names to replace your external imports
// eg. jquery: '$'
vue: 'Vue',
}

const config = {
input: 'src/index.js',
output: {
compact: true,
name: pascalCase(pkg.name),
file: pkg.main,
format: 'cjs',
exports: 'named',
globals,
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.ES_BUILD': JSON.stringify('false'),
}),
nodeResolve(),
commonjs(),
vue({ css: true, template: { optimizeSSR: true } }),
filesize(),
],
}

export default config
48 changes: 23 additions & 25 deletions build/rollup.config.es.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,28 @@
import { writeFileSync } from 'fs';
import vue from 'rollup-plugin-vue';
import css from 'rollup-plugin-css-only';
import filesize from 'rollup-plugin-filesize';
import CleanCSS from 'clean-css';
import base from './rollup.config.base';
import pkg from '../package.json';
import replace from '@rollup/plugin-replace'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import vue from 'rollup-plugin-vue'
import filesize from 'rollup-plugin-filesize'
import pkg from '../package.json'

const config = Object.assign({}, base, {
const config = {
input: 'src/index.js',
output: {
name: 'vue-clock',
name: pkg.name,
file: pkg.module,
format: 'es',
format: 'esm',
exports: 'named',
},
});
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.ES_BUILD': JSON.stringify('true'),
}),
nodeResolve(),
commonjs(),
vue({ css: true }),
filesize(),
],
}

config.plugins.push(vue({ template: { optimizeSSR: true }, css: false }));
config.plugins.push(
css({
output: function(styles) {
writeFileSync(
'dist/vue-clock.esm.css',
new CleanCSS().minify(styles).styles
);
},
})
);
config.plugins.push(filesize());

export default config;
export default config
18 changes: 0 additions & 18 deletions build/rollup.config.umd.js

This file was deleted.

37 changes: 37 additions & 0 deletions build/rollup.config.unpkg.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { pascalCase } from 'pascal-case'
import replace from '@rollup/plugin-replace'
import { nodeResolve } from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import vue from 'rollup-plugin-vue'
import filesize from 'rollup-plugin-filesize'
import pkg from '../package.json'

const globals = {
// Provide global variable names to replace your external imports
// eg. jquery: '$'
vue: 'Vue',
}

const config = {
input: 'src/index.js',
output: {
compact: true,
name: pascalCase(pkg.name),
file: pkg.unpkg,
format: 'iife',
exports: 'named',
globals,
},
plugins: [
replace({
'process.env.NODE_ENV': JSON.stringify('production'),
'process.env.ES_BUILD': JSON.stringify('false'),
}),
nodeResolve(),
commonjs(),
vue({ css: true }),
filesize(),
],
}

export default config
Loading

0 comments on commit 887cdaa

Please sign in to comment.