|
@@ -1,131 +1,125 @@
|
|
|
-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,
|
|
|
- }
|
|
|
-};
|
|
|
+import resolve from "@rollup/plugin-node-resolve";
|
|
|
+import replace from "@rollup/plugin-replace";
|
|
|
+import commonjs from "@rollup/plugin-commonjs";
|
|
|
+import json from "@rollup/plugin-json";
|
|
|
+import typescript from "@rollup/plugin-typescript";
|
|
|
+import svelte from "rollup-plugin-svelte";
|
|
|
+import babel from "@rollup/plugin-babel";
|
|
|
+import { terser } from "rollup-plugin-terser";
|
|
|
+import config from "sapper/config/rollup";
|
|
|
+import pkg from "./package.json";
|
|
|
+import { preprocess as sveltePreprocessConfig } from "./svelte.config";
|
|
|
+
|
|
|
+const preprocess = [
|
|
|
+ sveltePreprocessConfig,
|
|
|
+ // You could have more preprocessors, like MDsveX
|
|
|
+];
|
|
|
+
|
|
|
+const mode = process.env.NODE_ENV;
|
|
|
+const dev = mode === "development";
|
|
|
+const sourcemap = dev ? "inline" : false;
|
|
|
+const legacy = !!process.env.SAPPER_LEGACY_BUILD;
|
|
|
+
|
|
|
+const warningIsIgnored = (warning) => warning.message.includes(
|
|
|
+ "Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification",
|
|
|
+) || warning.message.includes("Circular dependency: node_modules");
|
|
|
+
|
|
|
+// Workaround for https://github.com/sveltejs/sapper/issues/1221
|
|
|
+const onwarn = (warning, _onwarn) => (warning.code === "CIRCULAR_DEPENDENCY" && /[/\\]@sapper[/\\]/.test(warning.message)) || warningIsIgnored(warning) || console.warn(warning.toString());
|
|
|
+
|
|
|
+export default {
|
|
|
+ client: {
|
|
|
+ input: config.client.input().replace(/\.js$/, ".ts"),
|
|
|
+ output: config.client.output(),
|
|
|
+ plugins: [
|
|
|
+ replace({
|
|
|
+ "process.browser": true,
|
|
|
+ "process.env.NODE_ENV": JSON.stringify(mode),
|
|
|
+ }),
|
|
|
+ svelte({
|
|
|
+ dev,
|
|
|
+ hydratable: true,
|
|
|
+ emitCss: true,
|
|
|
+ preprocess,
|
|
|
+ }),
|
|
|
+ resolve({
|
|
|
+ browser: true,
|
|
|
+ dedupe: ["svelte"],
|
|
|
+ }),
|
|
|
+ commonjs(),
|
|
|
+ typescript(),
|
|
|
+ json(),
|
|
|
+
|
|
|
+ legacy && babel({
|
|
|
+ extensions: [".js", ".mjs", ".html", ".svelte"],
|
|
|
+ babelHelpers: "runtime",
|
|
|
+ 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,
|
|
|
+ }),
|
|
|
+ ],
|
|
|
+
|
|
|
+ preserveEntrySignatures: false,
|
|
|
+ onwarn,
|
|
|
+ },
|
|
|
+
|
|
|
+ server: {
|
|
|
+ input: { server: config.server.input().server.replace(/\.js$/, ".ts") },
|
|
|
+ output: { ...config.server.output(), sourcemap },
|
|
|
+ plugins: [
|
|
|
+ replace({
|
|
|
+ "process.browser": false,
|
|
|
+ "process.env.NODE_ENV": JSON.stringify(mode),
|
|
|
+ "module.require": "require",
|
|
|
+ }),
|
|
|
+ svelte({
|
|
|
+ generate: "ssr",
|
|
|
+ dev,
|
|
|
+ preprocess,
|
|
|
+ }),
|
|
|
+ resolve({
|
|
|
+ dedupe: ["svelte"],
|
|
|
+ }),
|
|
|
+ commonjs(),
|
|
|
+ typescript(),
|
|
|
+ json(),
|
|
|
+ ],
|
|
|
+ external: Object.keys(pkg.dependencies).concat(
|
|
|
+ require("module").builtinModules || Object.keys(process.binding("natives")), // eslint-disable-line global-require
|
|
|
+ ),
|
|
|
+
|
|
|
+ preserveEntrySignatures: "strict",
|
|
|
+ onwarn,
|
|
|
+ },
|
|
|
+
|
|
|
+ serviceworker: {
|
|
|
+ input: config.serviceworker.input().replace(/\.js$/, ".ts"),
|
|
|
+ output: config.serviceworker.output(),
|
|
|
+ plugins: [
|
|
|
+ resolve(),
|
|
|
+ replace({
|
|
|
+ "process.browser": true,
|
|
|
+ "process.env.NODE_ENV": JSON.stringify(mode),
|
|
|
+ }),
|
|
|
+ commonjs(),
|
|
|
+ typescript(),
|
|
|
+ !dev && terser(),
|
|
|
+ ],
|
|
|
+
|
|
|
+ preserveEntrySignatures: false,
|
|
|
+ onwarn,
|
|
|
+ },
|
|
|
+};
|