Skip to content

Commit ef2dc56

Browse files
authored
Merge pull request #45 from janniks/test-rollup-changes
Revert to old rollup build script
2 parents 07f6a89 + 885b2a3 commit ef2dc56

File tree

9 files changed

+4468
-1038
lines changed

9 files changed

+4468
-1038
lines changed

babel.config.js

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,5 @@
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-
];
1+
const devPresets = ['@vue/babel-preset-app'];
2+
const buildPresets = ['@babel/preset-env'];
143
module.exports = {
15-
presets: process.env.NODE_ENV === "development" ? devPresets : buildPresets,
4+
presets: (process.env.NODE_ENV === 'development' ? devPresets : buildPresets),
165
};

build/postcss.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
import "../src/styles.css";

build/rollup.config.js

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ 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";
87
import replace from "@rollup/plugin-replace";
9-
import babel from "@rollup/plugin-babel";
8+
import babel from "rollup-plugin-babel";
9+
import postcss from "rollup-plugin-postcss";
1010
import { terser } from "rollup-plugin-terser";
11+
import postcssLogical from "postcss-logical";
1112
import minimist from "minimist";
1213

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

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-
2521
const argv = minimist(process.argv.slice(2));
2622

2723
const projectRoot = path.resolve(__dirname, "..");
@@ -31,33 +27,25 @@ const baseConfig = {
3127
plugins: {
3228
preVue: [
3329
alias({
34-
entries: [
35-
{
36-
find: "@",
37-
replacement: `${path.resolve(projectRoot, "src")}`,
38-
},
39-
],
30+
resolve: [".js", ".jsx", ".ts", ".tsx", ".vue"],
31+
entries: {
32+
"@": path.resolve(projectRoot, "src"),
33+
},
4034
}),
4135
],
4236
replace: {
4337
"process.env.NODE_ENV": JSON.stringify("production"),
38+
"process.env.ES_BUILD": JSON.stringify("false"),
4439
},
4540
vue: {
4641
css: true,
4742
template: {
4843
isProduction: true,
4944
},
5045
},
51-
postVue: [
52-
resolve({
53-
extensions: [".js", ".jsx", ".ts", ".tsx", ".vue"],
54-
}),
55-
commonjs(),
56-
],
5746
babel: {
5847
exclude: "node_modules/**",
5948
extensions: [".js", ".jsx", ".ts", ".tsx", ".vue"],
60-
babelHelpers: "bundled",
6149
},
6250
},
6351
};
@@ -83,30 +71,31 @@ const buildFormats = [];
8371
if (!argv.format || argv.format === "es") {
8472
const esConfig = {
8573
...baseConfig,
86-
input: "src/entry.esm.js",
8774
external,
8875
output: {
89-
file: "dist/esm.js", // custom
90-
format: "esm",
76+
file: "dist/esm.js",
77+
format: "es",
9178
exports: "named",
9279
},
9380
plugins: [
94-
replace(baseConfig.plugins.replace),
81+
replace({
82+
...baseConfig.plugins.replace,
83+
"process.env.ES_BUILD": JSON.stringify("true"),
84+
}),
9585
...baseConfig.plugins.preVue,
9686
vue(baseConfig.plugins.vue),
97-
...baseConfig.plugins.postVue,
9887
babel({
9988
...baseConfig.plugins.babel,
10089
presets: [
10190
[
10291
"@babel/preset-env",
10392
{
104-
...babelPresetEnvConfig,
10593
targets: esbrowserslist,
10694
},
10795
],
10896
],
10997
}),
98+
commonjs(),
11099
],
111100
};
112101
buildFormats.push(esConfig);
@@ -118,10 +107,10 @@ if (!argv.format || argv.format === "cjs") {
118107
external,
119108
output: {
120109
compact: true,
121-
file: "dist/ssr.js", // custom
110+
file: "dist/ssr.js",
122111
format: "cjs",
123112
name: "VueNotion",
124-
exports: "auto",
113+
exports: "named",
125114
globals,
126115
},
127116
plugins: [
@@ -134,8 +123,8 @@ if (!argv.format || argv.format === "cjs") {
134123
optimizeSSR: true,
135124
},
136125
}),
137-
...baseConfig.plugins.postVue,
138126
babel(baseConfig.plugins.babel),
127+
commonjs(),
139128
],
140129
};
141130
buildFormats.push(umdConfig);
@@ -147,18 +136,18 @@ if (!argv.format || argv.format === "iife") {
147136
external,
148137
output: {
149138
compact: true,
150-
file: "dist/min.js", // custom
139+
file: "dist/min.js",
151140
format: "iife",
152141
name: "VueNotion",
153-
exports: "auto",
142+
exports: "named",
154143
globals,
155144
},
156145
plugins: [
157146
replace(baseConfig.plugins.replace),
158147
...baseConfig.plugins.preVue,
159148
vue(baseConfig.plugins.vue),
160-
...baseConfig.plugins.postVue,
161149
babel(baseConfig.plugins.babel),
150+
commonjs(),
162151
terser({
163152
output: {
164153
ecma: 5,
@@ -169,5 +158,28 @@ if (!argv.format || argv.format === "iife") {
169158
buildFormats.push(unpkgConfig);
170159
}
171160

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+
172179
// Export config
173-
export default buildFormats;
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+
};

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.esm";
8+
import { NotionRenderer, getPageBlocks } from "@/entry";
99
1010
import "prismjs";
1111
import "prismjs/themes/prism.css";

0 commit comments

Comments
 (0)