Skip to content

Commit 155fecd

Browse files
committed
refactor: rollup config
1 parent 7d30287 commit 155fecd

File tree

1 file changed

+50
-44
lines changed

1 file changed

+50
-44
lines changed

rollup.config.ts

Lines changed: 50 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -69,50 +69,8 @@ packageFormats.forEach(format => {
6969
}
7070
})
7171

72-
// generate themes css
73-
const fs = require('fs');
74-
const csso = require('csso');
75-
const emptyJS = 'temp/empty.js'
76-
if (!fs.existsSync("temp")) fs.mkdirSync("temp");
77-
fs.writeFile(emptyJS, '', (err) => {
78-
if (err) throw err;
79-
console.log('empty.js created');
80-
})
81-
packageConfigs.push({
82-
input: emptyJS,
83-
output: { file: emptyJS },
84-
external: [],
85-
plugins: [
86-
copy({
87-
targets: [{
88-
src: './node_modules/quill/dist/quill.core.css',
89-
dest: './dist',
90-
rename: 'vue-quill.core.css',
91-
transform: (contents, filename) => {
92-
return csso.minify(contents.toString()).css
93-
}
94-
},
95-
{
96-
src: './node_modules/quill/dist/quill.bubble.css',
97-
dest: './dist',
98-
rename: 'vue-quill.bubble.css',
99-
transform: (contents, filename) => {
100-
return csso.minify(contents.toString()).css
101-
}
102-
},
103-
{
104-
src: './dist/vue-quill.snow.css',
105-
dest: './dist',
106-
transform: (contents, filename) => {
107-
return csso.minify(contents.toString()).css
108-
}
109-
}],
110-
hook: 'writeBundle',
111-
verbose: true,
112-
copyOnce: true
113-
})
114-
]
115-
})
72+
// generate themes
73+
packageConfigs.push(createThemesConfig())
11674

11775
export default packageConfigs
11876

@@ -248,3 +206,51 @@ function createMinifiedConfig(format) {
248206
]
249207
)
250208
}
209+
210+
function createThemesConfig() {
211+
const fs = require('fs');
212+
const csso = require('csso');
213+
// empty.js only used as a dummy input
214+
// and have nothing to do with the build
215+
const emptyJS = 'temp/empty.js'
216+
if (!fs.existsSync("temp")) fs.mkdirSync("temp");
217+
fs.writeFile(emptyJS, '', (err) => {
218+
if (err) throw err;
219+
console.log('empty.js created');
220+
})
221+
return {
222+
input: emptyJS,
223+
output: { file: emptyJS },
224+
external: [],
225+
plugins: [
226+
copy({
227+
targets: [{
228+
src: './node_modules/quill/dist/quill.core.css',
229+
dest: './dist',
230+
rename: 'vue-quill.core.css',
231+
transform: (contents, filename) => {
232+
return csso.minify(contents.toString()).css
233+
}
234+
},
235+
{
236+
src: './node_modules/quill/dist/quill.bubble.css',
237+
dest: './dist',
238+
rename: 'vue-quill.bubble.css',
239+
transform: (contents, filename) => {
240+
return csso.minify(contents.toString()).css
241+
}
242+
},
243+
{
244+
src: './dist/vue-quill.snow.css',
245+
dest: './dist',
246+
transform: (contents, filename) => {
247+
return csso.minify(contents.toString()).css
248+
}
249+
}],
250+
hook: 'writeBundle',
251+
verbose: true,
252+
copyOnce: true
253+
})
254+
]
255+
}
256+
}

0 commit comments

Comments
 (0)