-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
104 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,111 +1,111 @@ | ||
import { terser } from 'rollup-plugin-terser'; | ||
import autoPreprocess from 'svelte-preprocess'; | ||
import babel from 'rollup-plugin-babel'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import livereload from 'rollup-plugin-livereload'; | ||
import pkg from './package.json'; | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import svelte from 'rollup-plugin-svelte'; | ||
import { terser } from 'rollup-plugin-terser' | ||
import autoPreprocess from 'svelte-preprocess' | ||
import babel from 'rollup-plugin-babel' | ||
import commonjs from 'rollup-plugin-commonjs' | ||
import livereload from 'rollup-plugin-livereload' | ||
import pkg from './package.json' | ||
import resolve from 'rollup-plugin-node-resolve' | ||
import svelte from 'rollup-plugin-svelte' | ||
|
||
const production = !process.env.ROLLUP_WATCH; | ||
const production = !process.env.ROLLUP_WATCH | ||
const name = pkg.name | ||
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3') | ||
.replace(/^\w/, (m) => m.toUpperCase()) | ||
.replace(/-\w/g, (m) => m[1].toUpperCase()); | ||
.replace(/^(@\S+\/)?(svelte-)?(\S+)/, '$3') | ||
.replace(/^\w/, (m) => m.toUpperCase()) | ||
.replace(/-\w/g, (m) => m[1].toUpperCase()) | ||
|
||
export default { | ||
input: !production ? 'src/main.js' : 'src/components/components.module.js', | ||
output: !production | ||
? { | ||
sourcemap: true, | ||
format: 'iife', | ||
name: 'app', | ||
file: 'public/bundle.js', | ||
} | ||
: [ | ||
{ | ||
file: pkg.module, | ||
format: 'es', | ||
sourcemap: true, | ||
name, | ||
}, | ||
{ | ||
file: pkg.main, | ||
format: 'umd', | ||
sourcemap: true, | ||
name, | ||
}, | ||
], | ||
plugins: [ | ||
babel({ | ||
runtimeHelpers: true, | ||
}), | ||
svelte({ | ||
// enable run-time checks when not in production | ||
dev: !production, | ||
// we'll extract any component CSS out into | ||
// a separate file — better for performance | ||
css: (css) => { | ||
css.write('bundle.css'); | ||
}, | ||
input: !production ? 'src/main.js' : 'src/components/components.module.js', | ||
output: !production | ||
? { | ||
sourcemap: true, | ||
format: 'iife', | ||
name: 'app', | ||
file: 'public/bundle.js' | ||
} | ||
: [ | ||
{ | ||
file: pkg.module, | ||
format: 'es', | ||
sourcemap: true, | ||
name | ||
}, | ||
{ | ||
file: pkg.main, | ||
format: 'umd', | ||
sourcemap: true, | ||
name | ||
} | ||
], | ||
plugins: [ | ||
babel({ | ||
runtimeHelpers: true | ||
}), | ||
svelte({ | ||
// enable run-time checks when not in production | ||
dev: !production, | ||
// we'll extract any component CSS out into | ||
// a separate file — better for performance | ||
css: (css) => { | ||
css.write('bundle.css') | ||
}, | ||
|
||
/** | ||
* Auto preprocess supported languages with | ||
* '<template>'/'external src files' support | ||
**/ | ||
preprocess: autoPreprocess({ | ||
postcss: true, | ||
scss: { includePaths: ['src', 'node_modules'] }, | ||
}), | ||
}), | ||
/** | ||
* Auto preprocess supported languages with | ||
* '<template>'/'external src files' support | ||
**/ | ||
preprocess: autoPreprocess({ | ||
postcss: true, | ||
scss: { includePaths: ['src', 'node_modules'] } | ||
}) | ||
}), | ||
|
||
// If you have external dependencies installed from | ||
// npm, you'll most likely need these plugins. In | ||
// some cases you'll need additional configuration — | ||
// consult the documentation for details: | ||
// https://github.com/rollup/rollup-plugin-commonjs | ||
resolve({ | ||
browser: true, | ||
dedupe: ['svelte'], | ||
}), | ||
commonjs({ | ||
include: ['node_modules/**'], | ||
}), | ||
// If you have external dependencies installed from | ||
// npm, you'll most likely need these plugins. In | ||
// some cases you'll need additional configuration — | ||
// consult the documentation for details: | ||
// https://github.com/rollup/rollup-plugin-commonjs | ||
resolve({ | ||
browser: true, | ||
dedupe: ['svelte'] | ||
}), | ||
commonjs({ | ||
include: ['node_modules/**'] | ||
}), | ||
|
||
// In dev mode, call `npm run start` once | ||
// the bundle has been generated | ||
!production && serve(), | ||
// In dev mode, call `npm run start` once | ||
// the bundle has been generated | ||
!production && serve(), | ||
|
||
// Watch the `public` directory and refresh the | ||
// browser on changes when not in production | ||
!production && livereload('public'), | ||
// Watch the `public` directory and refresh the | ||
// browser on changes when not in production | ||
!production && livereload('public'), | ||
|
||
// If we're building for production (npm run build | ||
// instead of npm run dev), minify | ||
production && terser(), | ||
], | ||
watch: { | ||
clearScreen: false, | ||
}, | ||
}; | ||
// If we're building for production (npm run build | ||
// instead of npm run dev), minify | ||
production && terser() | ||
], | ||
watch: { | ||
clearScreen: false | ||
} | ||
} | ||
|
||
function serve() { | ||
let started = false; | ||
function serve () { | ||
let started = false | ||
|
||
return { | ||
writeBundle() { | ||
if (!started) { | ||
started = true; | ||
return { | ||
writeBundle () { | ||
if (!started) { | ||
started = true | ||
|
||
require('child_process').spawn( | ||
'npm', | ||
['run', 'start', '--', '--dev'], | ||
{ | ||
stdio: ['ignore', 'inherit', 'inherit'], | ||
shell: true, | ||
} | ||
); | ||
} | ||
}, | ||
}; | ||
require('child_process').spawn( | ||
'npm', | ||
['run', 'start', '--', '--dev'], | ||
{ | ||
stdio: ['ignore', 'inherit', 'inherit'], | ||
shell: true | ||
} | ||
) | ||
} | ||
} | ||
} | ||
} |