Skip to content
Snippets Groups Projects
Commit fc1da90c authored by David Trattnig's avatar David Trattnig
Browse files

chore: add JSON import plugin

parent c0148229
No related branches found
No related tags found
1 merge request!1Local settings via JSON and initial use of Context API
import svelte from 'rollup-plugin-svelte';
import sveltePreprocess from 'svelte-preprocess';
import typescript from "@rollup/plugin-typescript";
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import livereload from 'rollup-plugin-livereload';
import { terser } from 'rollup-plugin-terser';
import postcss from 'rollup-plugin-postcss';
import replace from '@rollup/plugin-replace';
import pkg from "./package.json";
const production = !process.env.ROLLUP_WATCH;
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import resolve from '@rollup/plugin-node-resolve'
import replace from '@rollup/plugin-replace'
import typescript from '@rollup/plugin-typescript'
import livereload from 'rollup-plugin-livereload'
import postcss from 'rollup-plugin-postcss'
import svelte from 'rollup-plugin-svelte'
import { terser } from 'rollup-plugin-terser'
import sveltePreprocess from 'svelte-preprocess'
import pkg from './package.json'
const production = !process.env.ROLLUP_WATCH
function serve() {
let server;
function toExit() {
if (server) server.kill(0);
}
return {
writeBundle() {
if (server) return;
server = require('child_process').spawn('npm', ['run', 'start', '--', '--dev'], {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
process.on('SIGTERM', toExit);
process.on('exit', toExit);
}
};
let server
function toExit() {
if (server) server.kill(0)
}
return {
writeBundle() {
if (server) return
server = require('child_process').spawn(
'npm',
['run', 'start', '--', '--dev'],
{
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
},
)
process.on('SIGTERM', toExit)
process.on('exit', toExit)
},
}
}
export default {
input: 'src/main.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/aura-player-bundle.js'
},
plugins: [
/** Inject App Version **/
replace({
preventAssignment: true,
APP_VERSION: pkg.version
}),
/** Handle HTML5 Web Components **/
svelte({
include: /\.wc\.svelte$/,
preprocess: sveltePreprocess({
sourceMap: !production,
}),
compilerOptions: {
// enable run-time checks when not in production
dev: !production,
customElement: true,
},
// store CSS in JavaScript
emitCss: false
}),
/** Handle Svelte Components **/
svelte({
exclude: /\.wc\.svelte$/,
preprocess: sveltePreprocess({
sourceMap: !production,
}),
compilerOptions: {
// enable run-time checks when not in production
dev: !production,
customElement: false,
},
// we'll extract any component CSS out into
// a separate file - better for performance
emitCss: true
}),
// we'll extract any component CSS out into
// a separate file - better for performance
// css({ output: 'aura-player-bundle.css' })
/** SASS Support */
postcss({
extract: true,
minimize: production,
use: [
[
'sass',
{
includePaths: ['./src', './src/theme', './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/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte']
}),
commonjs(),
/** TypeScript Support */
typeCheck(),
typescript({ rootDir: './src', sourceMap: !production }),
// 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'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser()
],
watch: {
clearScreen: false
}
};
input: 'src/main.ts',
output: {
sourcemap: true,
format: 'iife',
name: 'app',
file: 'public/build/aura-player-bundle.js',
},
plugins: [
/** Allow import of JSON Files **/
json({
compact: true,
}),
/** Inject App Version **/
replace({
preventAssignment: true,
__APP_VERSION__: pkg.version,
}),
/** Handle HTML5 Web Components **/
svelte({
include: /\.wc\.svelte$/,
preprocess: sveltePreprocess({
sourceMap: !production,
}),
compilerOptions: {
// enable run-time checks when not in production
dev: !production,
customElement: true,
},
// store CSS in JavaScript
emitCss: false,
}),
/** Handle Svelte Components **/
svelte({
exclude: /\.wc\.svelte$/,
preprocess: sveltePreprocess({
sourceMap: !production,
}),
compilerOptions: {
// enable run-time checks when not in production
dev: !production,
customElement: false,
},
// we'll extract any component CSS out into
// a separate file - better for performance
emitCss: true,
}),
// we'll extract any component CSS out into
// a separate file - better for performance
// css({ output: 'aura-player-bundle.css' })
/** SASS Support */
postcss({
extract: true,
minimize: production,
use: [
[
'sass',
{
includePaths: ['./src', './src/theme', './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/plugins/tree/master/packages/commonjs
resolve({
browser: true,
dedupe: ['svelte'],
}),
commonjs(),
/** TypeScript Support */
typeCheck(),
typescript({ rootDir: './src', sourceMap: !production }),
// 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'),
// If we're building for production (npm run build
// instead of npm run dev), minify
production && terser(),
],
watch: {
clearScreen: false,
},
}
function typeCheck() {
return {
writeBundle() {
require('child_process').spawn('svelte-check', {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true
});
}
}
}
\ No newline at end of file
return {
writeBundle() {
require('child_process').spawn('svelte-check', {
stdio: ['ignore', 'inherit', 'inherit'],
shell: true,
})
},
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment