Skip to content

Commit 2befbc9

Browse files
authored
Merge pull request #37 from janniks/sfc-reinstall
Update from vue sfc rollup
2 parents 90b7a5a + fa70f1a commit 2befbc9

File tree

10 files changed

+3549
-7456
lines changed

10 files changed

+3549
-7456
lines changed

babel.config.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
1-
const devPresets = ['@vue/babel-preset-app'];
2-
const buildPresets = ['@babel/preset-env'];
1+
const devPresets = ["@vue/babel-preset-app"];
2+
const buildPresets = [
3+
[
4+
"@babel/preset-env",
5+
// Config for @babel/preset-env
6+
{
7+
// Example: Always transpile optional chaining/nullish coalescing
8+
// include: [
9+
// /(optional-chaining|nullish-coalescing)/
10+
// ],
11+
},
12+
],
13+
];
314
module.exports = {
4-
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
15+
presets: process.env.NODE_ENV === "development" ? devPresets : buildPresets,
516
};

build/postcss.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

build/rollup.config.js

Lines changed: 33 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import path from "path";
44
import vue from "rollup-plugin-vue";
55
import alias from "@rollup/plugin-alias";
66
import commonjs from "@rollup/plugin-commonjs";
7+
import resolve from "@rollup/plugin-node-resolve";
78
import replace from "@rollup/plugin-replace";
8-
import babel from "rollup-plugin-babel";
9-
import postcss from "rollup-plugin-postcss";
9+
import babel from "@rollup/plugin-babel";
1010
import { terser } from "rollup-plugin-terser";
11-
import postcssLogical from "postcss-logical";
1211
import minimist from "minimist";
1312

1413
// Get browserslist config and remove ie from es build targets
@@ -18,6 +17,11 @@ const esbrowserslist = fs
1817
.split("\n")
1918
.filter((entry) => entry && entry.substring(0, 2) !== "ie");
2019

20+
// Extract babel preset-env config, to combine with esbrowserslist
21+
const babelPresetEnvConfig = require("../babel.config").presets.filter(
22+
(entry) => entry[0] === "@babel/preset-env"
23+
)[0][1];
24+
2125
const argv = minimist(process.argv.slice(2));
2226

2327
const projectRoot = path.resolve(__dirname, "..");
@@ -27,25 +31,33 @@ const baseConfig = {
2731
plugins: {
2832
preVue: [
2933
alias({
30-
resolve: [".js", ".jsx", ".ts", ".tsx", ".vue"],
31-
entries: {
32-
"@": path.resolve(projectRoot, "src"),
33-
},
34+
entries: [
35+
{
36+
find: "@",
37+
replacement: `${path.resolve(projectRoot, "src")}`,
38+
},
39+
],
3440
}),
3541
],
3642
replace: {
3743
"process.env.NODE_ENV": JSON.stringify("production"),
38-
"process.env.ES_BUILD": JSON.stringify("false"),
3944
},
4045
vue: {
4146
css: true,
4247
template: {
4348
isProduction: true,
4449
},
4550
},
51+
postVue: [
52+
resolve({
53+
extensions: [".js", ".jsx", ".ts", ".tsx", ".vue"],
54+
}),
55+
commonjs(),
56+
],
4657
babel: {
4758
exclude: "node_modules/**",
4859
extensions: [".js", ".jsx", ".ts", ".tsx", ".vue"],
60+
babelHelpers: "bundled",
4961
},
5062
},
5163
};
@@ -71,31 +83,30 @@ const buildFormats = [];
7183
if (!argv.format || argv.format === "es") {
7284
const esConfig = {
7385
...baseConfig,
86+
input: "src/entry.esm.js",
7487
external,
7588
output: {
76-
file: "dist/esm.js",
77-
format: "es",
89+
file: "dist/esm.js", // custom
90+
format: "esm",
7891
exports: "named",
7992
},
8093
plugins: [
81-
replace({
82-
...baseConfig.plugins.replace,
83-
"process.env.ES_BUILD": JSON.stringify("true"),
84-
}),
94+
replace(baseConfig.plugins.replace),
8595
...baseConfig.plugins.preVue,
8696
vue(baseConfig.plugins.vue),
97+
...baseConfig.plugins.postVue,
8798
babel({
8899
...baseConfig.plugins.babel,
89100
presets: [
90101
[
91102
"@babel/preset-env",
92103
{
104+
...babelPresetEnvConfig,
93105
targets: esbrowserslist,
94106
},
95107
],
96108
],
97109
}),
98-
commonjs(),
99110
],
100111
};
101112
buildFormats.push(esConfig);
@@ -107,10 +118,10 @@ if (!argv.format || argv.format === "cjs") {
107118
external,
108119
output: {
109120
compact: true,
110-
file: "dist/ssr.js",
121+
file: "dist/ssr.js", // custom
111122
format: "cjs",
112123
name: "VueNotion",
113-
exports: "named",
124+
exports: "auto",
114125
globals,
115126
},
116127
plugins: [
@@ -123,8 +134,8 @@ if (!argv.format || argv.format === "cjs") {
123134
optimizeSSR: true,
124135
},
125136
}),
137+
...baseConfig.plugins.postVue,
126138
babel(baseConfig.plugins.babel),
127-
commonjs(),
128139
],
129140
};
130141
buildFormats.push(umdConfig);
@@ -136,18 +147,18 @@ if (!argv.format || argv.format === "iife") {
136147
external,
137148
output: {
138149
compact: true,
139-
file: "dist/min.js",
150+
file: "dist/min.js", // custom
140151
format: "iife",
141152
name: "VueNotion",
142-
exports: "named",
153+
exports: "auto",
143154
globals,
144155
},
145156
plugins: [
146157
replace(baseConfig.plugins.replace),
147158
...baseConfig.plugins.preVue,
148159
vue(baseConfig.plugins.vue),
160+
...baseConfig.plugins.postVue,
149161
babel(baseConfig.plugins.babel),
150-
commonjs(),
151162
terser({
152163
output: {
153164
ecma: 5,
@@ -158,28 +169,5 @@ if (!argv.format || argv.format === "iife") {
158169
buildFormats.push(unpkgConfig);
159170
}
160171

161-
if (!argv.format || argv.format === "postcss") {
162-
const postCssConfig = {
163-
input: "build/postcss.js",
164-
output: {
165-
format: "es",
166-
file: "dist/styles.ignore",
167-
},
168-
plugins: [
169-
postcss({
170-
extract: true,
171-
minimize: true,
172-
plugins: [postcssLogical()],
173-
}),
174-
],
175-
};
176-
buildFormats.push(postCssConfig);
177-
}
178-
179172
// Export config
180-
export default (commandLineArgs) => {
181-
// Exporting a method enables command line args override
182-
// https://rollupjs.org/guide/en/#configuration-files
183-
delete commandLineArgs.format;
184-
return buildFormats;
185-
};
173+
export default buildFormats;

dev/serve.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import Vue from 'vue';
2-
import Dev from './serve.vue';
1+
import Vue from "vue";
2+
import Dev from "./serve.vue";
33

44
Vue.config.productionTip = false;
55

66
new Vue({
77
render: (h) => h(Dev),
8-
}).$mount('#app');
8+
}).$mount("#app");

dev/serve.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</template>
66

77
<script>
8-
import { NotionRenderer, getPageBlocks } from "@/entry";
8+
import { NotionRenderer, getPageBlocks } from "@/entry.esm";
99
1010
import "prismjs";
1111
import "prismjs/themes/prism.css";

0 commit comments

Comments
 (0)