123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- import resolve from 'rollup-plugin-node-resolve';
- import replace from 'rollup-plugin-replace';
- import commonjs from 'rollup-plugin-commonjs';
- import svelte from 'rollup-plugin-svelte';
- import babel from 'rollup-plugin-babel';
- import { terser } from 'rollup-plugin-terser';
- import config from 'sapper/config/rollup.js';
- import pkg from './package.json';
- import typescript from 'rollup-plugin-typescript2';
- import autoPreprocess from 'svelte-preprocess';
- const mode = process.env.NODE_ENV;
- const dev = mode === 'development';
- const legacy = !!process.env.SAPPER_LEGACY_BUILD;
- const onwarn = (warning, onwarn) => (warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) || onwarn(warning);
- const dedupe = importee => importee === 'svelte' || importee.startsWith('svelte/');
- const preprocessOptions = {
- scss: false,
- transformers: {
- // scss: {
- // includePaths: [
- // 'node_modules',
- // 'src'
- // ]
- // },
- postcss: {
- plugins: [
- require('postcss-import'),
- require('tailwindcss'),
- require('postcss-nested'),
- require('autoprefixer'),
- ]
- }
- },
- }
- export default {
- client: {
- input: config.client.input(),
- output: config.client.output(),
- plugins: [
- replace({
- 'process.browser': true,
- 'process.env.NODE_ENV': JSON.stringify(mode)
- }),
- svelte({
- dev,
- hydratable: true,
- emitCss: true,
- preprocess: autoPreprocess(preprocessOptions)
- }),
- resolve({
- browser: true,
- dedupe
- }),
- commonjs(),
- legacy && babel({
- extensions: ['.js', '.mjs', '.html', '.svelte'],
- runtimeHelpers: true,
- exclude: ['node_modules/@babel/**'],
- presets: [
- ['@babel/preset-env', {
- targets: '> 0.25%, not dead'
- }]
- ],
- plugins: [
- '@babel/plugin-syntax-dynamic-import',
- ['@babel/plugin-transform-runtime', {
- useESModules: true
- }]
- ]
- }),
- !dev && terser({
- module: true
- })
- ],
- onwarn,
- },
- server: {
- input: { server: config.server.input().server.replace(/\.js$/, '.ts') },
- output: {
- ...config.server.output(),
- sourcemap: process.env.NODE_ENV == "development"
- },
- plugins: [
- replace({
- 'process.browser': false,
- 'process.env.NODE_ENV': JSON.stringify(mode)
- }),
- svelte({
- generate: 'ssr',
- dev,
- preprocess: autoPreprocess(preprocessOptions)
- }),
- resolve({
- dedupe,
- extensions: ['.mjs', '.js', '.ts', '.json']
- }),
- commonjs(),
- typescript()
- ],
- external: Object.keys(pkg.dependencies).concat(
- require('module').builtinModules || Object.keys(process.binding('natives'))
- ),
- onwarn,
- },
- serviceworker: {
- input: config.serviceworker.input(),
- output: config.serviceworker.output(),
- plugins: [
- resolve(),
- replace({
- 'process.browser': true,
- 'process.env.NODE_ENV': JSON.stringify(mode)
- }),
- commonjs(),
- !dev && terser()
- ],
- onwarn,
- }
- };
|