Skip to content

Commit e2cf5cc

Browse files
authored
Merge pull request #172 from merceyz/bundle-size
fix: reduce bundle size
2 parents c884b4b + 3a099da commit e2cf5cc

File tree

6 files changed

+94
-19
lines changed

6 files changed

+94
-19
lines changed

babel.config.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
module.exports = {
22
presets: [
3-
'@vue/app',
4-
],
3+
[
4+
'@vue/cli-plugin-babel/preset',
5+
{
6+
absoluteRuntime: false,
7+
version: require('@babel/runtime/package.json').version
8+
}
9+
]
10+
]
511
};

build/rollup.config.base.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import babel from 'rollup-plugin-babel';
2-
import resolve from 'rollup-plugin-node-resolve';
32
import vue from 'rollup-plugin-vue';
43
import cjs from 'rollup-plugin-commonjs';
54
import replace from 'rollup-plugin-replace';
@@ -11,9 +10,6 @@ const config = require('../package.json');
1110
export default {
1211
input: 'src/index.js',
1312
plugins: [
14-
resolve({
15-
mainFields: ['module', 'jsnext:main', 'main', 'browser'],
16-
}),
1713
vue({
1814
css: true,
1915
}),

build/rollup.config.browser.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { terser } from 'rollup-plugin-terser';
2+
import resolve from 'rollup-plugin-node-resolve';
23
import base from './rollup.config.base';
34

45
const config = Object.assign({}, base, {
@@ -12,4 +13,10 @@ const config = Object.assign({}, base, {
1213

1314
config.plugins.push(terser());
1415

16+
config.plugins.push(
17+
resolve({
18+
mainFields: ["module", "jsnext:main", "main", "browser"]
19+
})
20+
);
21+
1522
export default config;

build/rollup.config.umd.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import resolve from 'rollup-plugin-node-resolve';
12
import base from './rollup.config.base';
23

34
const config = Object.assign({}, base, {
@@ -9,4 +10,10 @@ const config = Object.assign({}, base, {
910
},
1011
});
1112

13+
config.plugins.push(
14+
resolve({
15+
mainFields: ["module", "jsnext:main", "main", "browser"]
16+
})
17+
);
18+
1219
export default config;

package-lock.json

Lines changed: 64 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
"scripts": {
1313
"dev": "vue-cli-service serve",
1414
"demo": "vue-cli-service build",
15-
"build": "set NODE_ENV=production && npm run build:browser && npm run build:es && npm run build:umd",
16-
"build:browser": "rollup --config build/rollup.config.browser.js",
17-
"build:es": "rollup --config build/rollup.config.es.js",
18-
"build:umd": "rollup --config build/rollup.config.umd.js",
15+
"build": "npm run build:browser && npm run build:es && npm run build:umd",
16+
"build:browser": "cross-env NODE_ENV=production rollup --config build/rollup.config.browser.js",
17+
"build:es": "cross-env NODE_ENV=production rollup --config build/rollup.config.es.js",
18+
"build:umd": "cross-env NODE_ENV=production rollup --config build/rollup.config.umd.js",
1919
"lint": "vue-cli-service lint",
2020
"test:unit": "vue-cli-service test:unit"
2121
},
@@ -26,7 +26,9 @@
2626
"module": "dist/vue-tel-input.esm.js",
2727
"unpkg": "dist/vue-tel-input.min.js",
2828
"dependencies": {
29-
"awesome-phonenumber": "^2.15.0"
29+
"@babel/runtime": "^7.8.4",
30+
"awesome-phonenumber": "^2.15.0",
31+
"core-js": "^3.6.4"
3032
},
3133
"devDependencies": {
3234
"@babel/plugin-proposal-object-rest-spread": "^7.0.0",
@@ -40,7 +42,7 @@
4042
"babel-core": "7.0.0-bridge.0",
4143
"babel-eslint": "^10.0.3",
4244
"babel-jest": "^23.6.0",
43-
"core-js": "^3.6.4",
45+
"cross-env": "^7.0.2",
4446
"eslint": "^6.7.2",
4547
"eslint-plugin-jest": "^22.15.1",
4648
"eslint-plugin-vue": "^6.1.2",

0 commit comments

Comments
 (0)