The namegen5 website.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

135 lines
3.1 KiB

4 years ago
  1. import path from 'path';
  2. import resolve from '@rollup/plugin-node-resolve';
  3. import replace from '@rollup/plugin-replace';
  4. import json from '@rollup/plugin-json';
  5. import { wasm } from '@rollup/plugin-wasm';
  6. import commonjs from '@rollup/plugin-commonjs';
  7. import url from '@rollup/plugin-url';
  8. import svelte from 'rollup-plugin-svelte';
  9. import babel from '@rollup/plugin-babel';
  10. import { terser } from 'rollup-plugin-terser';
  11. import config from 'sapper/config/rollup.js';
  12. import pkg from './package.json';
  13. import rust from "@wasm-tool/rollup-plugin-rust";
  14. const mode = process.env.NODE_ENV;
  15. const dev = mode === 'development';
  16. const legacy = !!process.env.SAPPER_LEGACY_BUILD;
  17. const onwarn = (warning, onwarn) =>
  18. (warning.code === 'MISSING_EXPORT' && /'preload'/.test(warning.message)) ||
  19. (warning.code === 'CIRCULAR_DEPENDENCY' && /[/\\]@sapper[/\\]/.test(warning.message)) ||
  20. onwarn(warning);
  21. export default {
  22. client: {
  23. input: config.client.input(),
  24. output: config.client.output(),
  25. plugins: [
  26. replace({
  27. preventAssignment: true,
  28. values:{
  29. 'process.browser': true,
  30. 'process.env.NODE_ENV': JSON.stringify(mode)
  31. },
  32. }),
  33. wasm(),
  34. svelte({
  35. compilerOptions: {
  36. dev,
  37. hydratable: true
  38. }
  39. }),
  40. url({
  41. sourceDir: path.resolve(__dirname, 'src/node_modules/images'),
  42. publicPath: '/client/'
  43. }),
  44. resolve({
  45. browser: true,
  46. dedupe: ['svelte']
  47. }),
  48. commonjs(),
  49. json({compact: true}),
  50. rust(),
  51. legacy && babel({
  52. extensions: ['.js', '.mjs', '.html', '.svelte'],
  53. babelHelpers: 'runtime',
  54. exclude: ['node_modules/@babel/**'],
  55. presets: [
  56. ['@babel/preset-env', {
  57. targets: '> 0.25%, not dead'
  58. }]
  59. ],
  60. plugins: [
  61. '@babel/plugin-syntax-dynamic-import',
  62. ['@babel/plugin-transform-runtime', {
  63. useESModules: true
  64. }]
  65. ]
  66. }),
  67. !dev && terser({
  68. module: true
  69. })
  70. ],
  71. preserveEntrySignatures: false,
  72. onwarn,
  73. },
  74. server: {
  75. input: config.server.input(),
  76. output: config.server.output(),
  77. plugins: [
  78. replace({
  79. preventAssignment: true,
  80. values:{
  81. 'process.browser': false,
  82. 'process.env.NODE_ENV': JSON.stringify(mode)
  83. },
  84. }),
  85. svelte({
  86. compilerOptions: {
  87. dev,
  88. generate: 'ssr',
  89. hydratable: true
  90. },
  91. emitCss: false
  92. }),
  93. url({
  94. sourceDir: path.resolve(__dirname, 'src/node_modules/images'),
  95. publicPath: '/client/',
  96. emitFiles: false // already emitted by client build
  97. }),
  98. resolve({
  99. dedupe: ['svelte']
  100. }),
  101. rust(),
  102. commonjs()
  103. ],
  104. external: Object.keys(pkg.dependencies).concat(require('module').builtinModules),
  105. preserveEntrySignatures: 'strict',
  106. onwarn,
  107. },
  108. serviceworker: {
  109. input: config.serviceworker.input(),
  110. output: config.serviceworker.output(),
  111. plugins: [
  112. resolve(),
  113. replace({
  114. preventAssignment: true,
  115. values:{
  116. 'process.browser': true,
  117. 'process.env.NODE_ENV': JSON.stringify(mode)
  118. },
  119. }),
  120. commonjs(),
  121. rust(),
  122. !dev && terser()
  123. ],
  124. preserveEntrySignatures: false,
  125. onwarn,
  126. }
  127. };