1
1
2
-
2
+ const svelte = require ( 'rollup-plugin-svelte-hot' )
3
+ const resolve = require ( '@rollup/plugin-node-resolve' ) . default
4
+ const commonjs = require ( '@rollup/plugin-commonjs' )
5
+ const { terser } = require ( 'rollup-plugin-terser' )
6
+ const hmr = require ( 'rollup-plugin-hot' )
7
+ const livereload = require ( 'rollup-plugin-livereload' )
3
8
const { readFileSync } = require ( 'fs-extra' )
4
9
5
10
/** @type {RoxiPluginHookFunction } */
6
11
module . exports = function rollup ( app , params ) {
12
+ const isNollup = app . config . roxi . plugins . find ( p => p . name === 'nollup' )
7
13
const { buildDir, staticDir } = app . config . roxi
8
14
const { production } = app . state
9
15
@@ -14,13 +20,23 @@ module.exports = function rollup(app, params) {
14
20
input : `src/main.js` ,
15
21
preserveEntrySignatures : false ,
16
22
output : {
17
- name : 'routify_app ' ,
23
+ name : 'roxi_app ' ,
18
24
sourcemap : true ,
19
25
format : 'esm' , dir : buildDir
20
26
} ,
21
- plugins : [ ] ,
22
- pluginsCfg : {
23
- mainJsTransform : {
27
+ pluginsMap : { svelte, resolve, commonjs, terser, hmr, livereload } ,
28
+ plugins : {
29
+ terser : production && { } ,
30
+ svelte : app . config . svelte ,
31
+ // resolve matching modules from current working directory
32
+ resolve : {
33
+ browser : true ,
34
+ dedupe : importee => ! ! importee . match ( / s v e l t e ( \/ | $ ) / )
35
+ } ,
36
+ commonjs : { } ,
37
+ terser : production && { } , // minify
38
+ livereload : ! production && ! isNollup && distDir ,
39
+ _mainJsTransform : {
24
40
transform : ( code , id ) => {
25
41
if ( id . match ( / [ / \\ ] s r c [ / \\ ] m a i n .j s $ / ) ) {
26
42
const tmpl = readFileSync ( __dirname + '/../../shared/main.template.js' , 'utf-8' )
@@ -31,11 +47,8 @@ module.exports = function rollup(app, params) {
31
47
}
32
48
}
33
49
} ,
34
- resolve : {
35
- browser : true ,
36
- dedupe : importee => ! ! importee . match ( / s v e l t e ( \/ | $ ) / )
37
- } ,
38
- hmr : { inMemory : true , public : staticDir }
50
+
51
+ hmr : production && { inMemory : true , public : staticDir }
39
52
} ,
40
53
watch : {
41
54
clearScreen : false ,
0 commit comments