Skip to content

Commit

Permalink
Merge pull request #6 from element-plus/feat/add-index-min-js
Browse files Browse the repository at this point in the history
feat/add-index-min-js
  • Loading branch information
jw-foss committed Dec 29, 2020
2 parents adb9e87 + 25c1f0b commit f8010c4
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 22 deletions.
57 changes: 38 additions & 19 deletions configs/rollup.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
const path = require('path')
const rollup = require('rollup')
const typescript = require('rollup-plugin-typescript2')
const path = require("path");
const rollup = require("rollup");
const typescript = require("rollup-plugin-typescript2");
const { terser } = require("rollup-plugin-terser");

const root = path.resolve(__dirname, '..');
const root = path.resolve(__dirname, "..");
const esm = {
file: path.resolve(root, './build/es/index.js'),
format: 'esm',
name: 'icons',
file: path.resolve(root, "./build/es/index.js"),
format: "esm",
name: "icons",
sourcemap: false,
};

const cjs = {
file: path.resolve(root, './build/lib/index.js'),
format: 'cjs',
exports: 'named',
file: path.resolve(root, "./build/lib/index.js"),
format: "cjs",
exports: "named",
sourcemap: false,
}
};

const minified = {
file: path.resolve(root, "./build/lib/index.min.js"),
format: "cjs",
exports: "named",
plugins: [terser({
output: {
comments: () => false,
}
})],
sourcemap: false,
};

rollup.rollup({
input: path.resolve(root, './packages/index.ts'),
plugins: [typescript()],
external: ['vue']
}).then(async bundle => {
await Promise.all([bundle.write(esm), bundle.write(cjs)]);
console.log('full bundle built success');
});
rollup
.rollup({
input: path.resolve(root, "./packages/index.ts"),
plugins: [typescript()],
external: ["vue"],
})
.then(async (bundle) => {
await Promise.all([
bundle.write(esm),
bundle.write(cjs),
bundle.write(minified),
]);
console.log("full bundle built success");
});
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"devDependencies": {
"@vue/compiler-sfc": "^3.0.2",
"rollup": "^2.35.1",
"rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.29.0",
"svgo": "^1.3.2",
"tslib": "^2.0.3",
Expand All @@ -29,4 +30,4 @@
"type": "git",
"url": "https://github.com/element-plus/element-plus-icons.git"
}
}
}
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2112,8 +2112,8 @@ rollup-plugin-dynamic-import-variables@^1.1.0:

rollup-plugin-terser@^7.0.2:
version "7.0.2"
resolved "https://registry.npm.taobao.org/rollup-plugin-terser/download/rollup-plugin-terser-7.0.2.tgz?cache=0&sync_timestamp=1600350654805&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Frollup-plugin-terser%2Fdownload%2Frollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
integrity sha1-6Pu6SGmYGy3DWufopQLVxsBNMk0=
resolved "https://registry.yarnpkg.com/rollup-plugin-terser/-/rollup-plugin-terser-7.0.2.tgz#e8fbba4869981b2dc35ae7e8a502d5c6c04d324d"
integrity sha512-w3iIaU4OxcF52UUXiZNsNeuXIMDvFrr+ZXK6bFZ0Q60qyVfq4uLptoS4bbq3paG3x216eQllFZX7zt6TIImguQ==
dependencies:
"@babel/code-frame" "^7.10.4"
jest-worker "^26.2.1"
Expand Down

0 comments on commit f8010c4

Please sign in to comment.