Skip to content

Commit e06412d

Browse files
committed
fix: rollup bundle external vue
1 parent ea3436a commit e06412d

File tree

4 files changed

+225
-45
lines changed

4 files changed

+225
-45
lines changed

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
"bump": "standard-version",
1717
"test": "npm run unit",
1818
"lint": "eslint --ext .js,.vue ./src ./example --fix",
19-
"icon": "node build/build.icon.js",
20-
"build": "node build/build.js",
19+
"icon": "node scripts/icon.js",
20+
"build": "cross-env NODE_ENV=production node scripts/build.js",
2121
"dev": "webpack-dev-server --hot --inline --config ./example/webpack.config.js",
2222
"start": "npm run dev",
23-
"build:example": "node build/build.example.js",
23+
"build:example": "cross-env NODE_ENV=production webpack --config ./example/webpack.config.js",
2424
"gh": "gh-pages -d example/dist",
2525
"deploy": "npm run build:example && npm run gh",
2626
"release": "npm run build && npm run bump && git push --follow-tags origin master && npm publish"
@@ -29,6 +29,7 @@
2929
"dependencies": {
3030
"nanoid": "^1.0.1",
3131
"spectre.css": "^0.5.0",
32+
"vue": "^2.5.22",
3233
"vue-page-designer-widgets": "^0.1.1",
3334
"vue-server-renderer": "^2.5.17"
3435
},
@@ -41,6 +42,7 @@
4142
"chalk": "^2.0.1",
4243
"clean-webpack-plugin": "^0.1.19",
4344
"copy-webpack-plugin": "^4.0.1",
45+
"cross-env": "^5.2.0",
4446
"css-loader": "^0.28.0",
4547
"eslint": "^5.3.0",
4648
"eslint-config-standard": "^11.0.0",
@@ -64,16 +66,16 @@
6466
"rollup": "^0.64.1",
6567
"rollup-plugin-buble": "^0.19.2",
6668
"rollup-plugin-commonjs": "^9.1.5",
67-
"rollup-plugin-css-only": "^0.4.0",
6869
"rollup-plugin-node-resolve": "^3.0.0",
70+
"rollup-plugin-postcss": "^1.6.3",
6971
"rollup-plugin-replace": "^2.0.0",
7072
"rollup-plugin-uglify": "^4.0.0",
7173
"rollup-plugin-vue": "^4.3.2",
7274
"sass-loader": "^6.0.6",
7375
"standard-version": "^4.2.0",
7476
"style-loader": "^0.22.1",
77+
"uglify-es": "^3.3.9",
7578
"util": "^0.11.0",
76-
"vue": "^2.5.17",
7779
"vue-loader": "^15.3.0",
7880
"vue-template-compiler": "^2.5.17",
7981
"webpack": "^4.29.0",

scripts/config.js

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
const path = require('path');
22
const fs = require('fs');
33
const replace = require('rollup-plugin-replace');
4-
const vue = require('rollup-plugin-vue').default;
4+
const vue = require('rollup-plugin-vue');
55
const resolve = require('rollup-plugin-node-resolve');
6-
const css = require('rollup-plugin-css-only');
6+
const postcss = require('rollup-plugin-postcss');
77
const buble = require('rollup-plugin-buble');
88
const commonjs = require('rollup-plugin-commonjs');
99
const filesize = require('filesize');
1010
const gzipSize = require('gzip-size');
1111
const { uglify } = require('rollup-plugin-uglify');
12+
const { minify } = require('uglify-es');
1213

1314
const version = process.env.VERSION || require('../package.json').version;
1415

@@ -48,17 +49,23 @@ function genConfig (options) {
4849
const config = {
4950
description: '',
5051
input: {
52+
external: ['vue'],
5153
input: options.input || common.paths.input,
5254
plugins: [
5355
commonjs(),
5456
replace({ __VERSION__: version }),
55-
css(),
57+
postcss({
58+
extract: true
59+
}),
5660
vue({ css: false }),
5761
resolve(),
58-
buble()
62+
buble({ exclude: 'node_modules/**' })
5963
]
6064
},
6165
output: {
66+
globals: {
67+
'vue': 'Vue'
68+
},
6269
banner: common.banner,
6370
name: options.name,
6471
format: options.format,
@@ -73,7 +80,7 @@ function genConfig (options) {
7380
}
7481

7582
if (options.env === 'production') {
76-
config.input.plugins.push(uglify());
83+
config.input.plugins.push(uglify({}, minify));
7784
}
7885

7986
return config;

scripts/icon.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var fs = require('fs')
2+
var path = require('path')
3+
var feather = require('feather-icons')
4+
5+
var icons = Object.keys(feather.icons)
6+
.map(key => `<symbol viewBox="${feather.icons[key].attrs.viewBox}" width="${feather.icons[key].attrs.width}" height="${feather.icons[key].attrs.height}" id="${key}">${feather.icons[key].toString()}</symbol>`);
7+
8+
fs.writeFileSync(path.resolve(__dirname, '../static/icons.svg'), `<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><defs>${icons.join('')}</defs></svg>`);
9+
10+
console.log(Object.keys(feather.icons).length + ' icon generated.')

0 commit comments

Comments
 (0)