Skip to content

Commit 55593c9

Browse files
committed
fix: separate esm and cjs rollups
1 parent 1f0d4e5 commit 55593c9

File tree

1 file changed

+23
-18
lines changed

1 file changed

+23
-18
lines changed

rollup.config.js

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,8 @@ import pkg from "./package.json";
88

99
const resolve = (_path) => path.resolve(__dirname, _path);
1010

11-
export default {
11+
const rootConfig = {
1212
input: resolve("./src/index.js"),
13-
output: [
14-
{
15-
file: pkg.main,
16-
name: "VueLive",
17-
format: "cjs",
18-
exports: "named", // remove warning about mixed exports
19-
},
20-
{
21-
file: pkg.module,
22-
format: "es", // the preferred format
23-
},
24-
],
2513
plugins: [
2614
commonjs(),
2715
babel({
@@ -31,11 +19,6 @@ export default {
3119
extensions: [".js"],
3220
babelHelpers: "runtime",
3321
}),
34-
vue({
35-
template: {
36-
isProduction: true,
37-
},
38-
}),
3922
css(),
4023
analyze({ summaryOnly: true }),
4124
],
@@ -53,3 +36,25 @@ export default {
5336
"@vue/compiler-core/dist/compiler-core.cjs",
5437
],
5538
};
39+
40+
export default [
41+
// ESM build to be used with webpack/rollup.
42+
{
43+
...rootConfig,
44+
output: {
45+
format: "esm",
46+
file: pkg.module,
47+
},
48+
plugins: [...rootConfig.plugins, vue()],
49+
},
50+
// SSR build.
51+
{
52+
...rootConfig,
53+
output: {
54+
format: "cjs",
55+
file: pkg.main,
56+
exports: "named", // remove warning about mixed exports
57+
},
58+
plugins: [...rootConfig.plugins, vue({ template: { optimizeSSR: true } })],
59+
},
60+
];

0 commit comments

Comments
 (0)