|
@@ -11,8 +11,8 @@ import pkg from "./package.json";
|
|
import { preprocess as sveltePreprocessConfig } from "./svelte.config";
|
|
import { preprocess as sveltePreprocessConfig } from "./svelte.config";
|
|
|
|
|
|
const preprocess = [
|
|
const preprocess = [
|
|
- sveltePreprocessConfig,
|
|
|
|
- // You could have more preprocessors, like MDsveX
|
|
|
|
|
|
+ sveltePreprocessConfig,
|
|
|
|
+ // You could have more preprocessors, like MDsveX
|
|
];
|
|
];
|
|
|
|
|
|
const mode = process.env.NODE_ENV;
|
|
const mode = process.env.NODE_ENV;
|
|
@@ -21,105 +21,105 @@ const sourcemap = dev ? "inline" : false;
|
|
const legacy = !!process.env.SAPPER_LEGACY_BUILD;
|
|
const legacy = !!process.env.SAPPER_LEGACY_BUILD;
|
|
|
|
|
|
const warningIsIgnored = (warning) => warning.message.includes(
|
|
const warningIsIgnored = (warning) => warning.message.includes(
|
|
- "Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification",
|
|
|
|
|
|
+ "Use of eval is strongly discouraged, as it poses security risks and may cause issues with minification",
|
|
) || warning.message.includes("Circular dependency: node_modules");
|
|
) || warning.message.includes("Circular dependency: node_modules");
|
|
|
|
|
|
// Workaround for https://github.com/sveltejs/sapper/issues/1221
|
|
// 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());
|
|
const onwarn = (warning, _onwarn) => (warning.code === "CIRCULAR_DEPENDENCY" && /[/\\]@sapper[/\\]/.test(warning.message)) || warningIsIgnored(warning) || console.warn(warning.toString());
|
|
|
|
|
|
export default {
|
|
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(),
|
|
|
|
|
|
+ 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,
|
|
|
|
- }],
|
|
|
|
- ],
|
|
|
|
- }),
|
|
|
|
|
|
+ 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,
|
|
|
|
- }),
|
|
|
|
- ],
|
|
|
|
|
|
+ !dev && terser({
|
|
|
|
+ module: true,
|
|
|
|
+ }),
|
|
|
|
+ ],
|
|
|
|
|
|
- preserveEntrySignatures: false,
|
|
|
|
- onwarn,
|
|
|
|
- },
|
|
|
|
|
|
+ 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
|
|
|
|
- ),
|
|
|
|
|
|
+ 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,
|
|
|
|
- },
|
|
|
|
|
|
+ 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(),
|
|
|
|
- ],
|
|
|
|
|
|
+ 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,
|
|
|
|
- },
|
|
|
|
|
|
+ preserveEntrySignatures: false,
|
|
|
|
+ onwarn,
|
|
|
|
+ },
|
|
};
|
|
};
|