nuxt.config.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. import { execSync } from 'child_process'
  2. import webpack from 'webpack'
  3. const hooks = (nuxtConfig) => ({
  4. 'generate:page': (page) => {
  5. page.html = modifyHtml(page.html)
  6. },
  7. 'render:route': (url, page, { req, res }) => {
  8. page.html = modifyHtml(page.html)
  9. }
  10. })
  11. let hasSourceMaps = '#source-map'
  12. if (process.env.NODE_ENV !== 'development') {
  13. // eslint-disable-next-line no-console
  14. console.log('NODE_ENV', process.env.NODE_ENV)
  15. hasSourceMaps = false
  16. }
  17. function getCurrentCommit() {
  18. try {
  19. return execSync('git rev-parse HEAD')
  20. .toString()
  21. .trim()
  22. .substr(0, 7)
  23. } catch (e) {
  24. console.error('Failed to get git commit', e.message)
  25. return 'debug'
  26. }
  27. }
  28. const modifyHtml = (html) => {
  29. return html.replace(/data-n-head=""|data-n-head="true"/g, '')
  30. }
  31. export default {
  32. target: 'static',
  33. ssr: false,
  34. /*
  35. ** Headers of the page
  36. */
  37. generate: {
  38. concurrency: 1,
  39. fallback: true
  40. },
  41. head: {
  42. title: 'Tornado.cash',
  43. meta: [
  44. { charset: 'utf-8' },
  45. {
  46. 'http-equiv': 'Content-Security-Policy',
  47. content:
  48. "img-src 'self' data:;font-src data:;style-src 'self' 'unsafe-inline';connect-src *;script-src 'self' 'unsafe-eval' 'unsafe-inline';default-src 'self';object-src 'none';base-uri 'none';upgrade-insecure-requests;child-src blob:;worker-src blob:;"
  49. },
  50. {
  51. name: 'Referer-Policy',
  52. content: 'no-referrer'
  53. },
  54. {
  55. name: 'viewport',
  56. content: 'width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no'
  57. },
  58. { name: 'theme-color', content: '#000403' },
  59. {
  60. hid: 'description',
  61. name: 'description',
  62. content: 'Non-custodial Ethereum Privacy solution.'
  63. },
  64. {
  65. hid: 'og:title',
  66. property: 'og:title',
  67. content: 'Tornado.Cash'
  68. },
  69. {
  70. hid: 'og:description',
  71. property: 'og:description',
  72. content: 'Non-custodial, trustless, serverless, private transactions on Ethereum network'
  73. },
  74. {
  75. hid: 'og:url',
  76. property: 'og:url',
  77. content: 'https://tornado.cash'
  78. },
  79. {
  80. hid: 'og:type',
  81. property: 'og:type',
  82. content: 'website'
  83. },
  84. {
  85. hid: 'og:image',
  86. property: 'og:image',
  87. content: 'https://tornado.cash/tw.png'
  88. },
  89. {
  90. hid: 'description',
  91. name: 'description',
  92. content: 'Non-custodial, trustless, serverless, private transactions on Ethereum network'
  93. },
  94. {
  95. hid: 'keywords',
  96. name: 'keywords',
  97. content:
  98. 'Tornado, Ethereum, ERC20, dapp, smart contract, decentralized, metamask, zksnark, zero knowledge'
  99. }
  100. ],
  101. link: [
  102. { rel: 'manifest', href: '/manifest.json' },
  103. { rel: 'shortcut icon', type: 'image/x-icon', href: '/favicon/favicon.ico' },
  104. { rel: 'apple-touch-icon', href: '/favicon/apple-touch-icon.png' }
  105. ]
  106. },
  107. /*
  108. ** Customize the progress-bar color
  109. */
  110. loading: { color: '#94febf', height: '5px', duration: 5000 },
  111. /*
  112. ** Global CSS
  113. */
  114. css: ['@/assets/styles/app.scss'],
  115. /*
  116. ** Plugins to load before mounting the App
  117. */
  118. plugins: [
  119. '~/plugins/ipfs.js',
  120. { src: '~plugins/clipboard', ssr: false },
  121. { src: '~plugins/detectIPFS', ssr: false },
  122. { src: '~plugins/localStorage', ssr: false },
  123. { src: '~plugins/preventMultitabs', ssr: false },
  124. { src: '~plugins/idb', ssr: false },
  125. { src: '~plugins/vidle', ssr: false },
  126. { src: '~plugins/sessionStorage', ssr: false },
  127. '~plugins/numbro/numbro',
  128. '~/plugins/i18n.js'
  129. ],
  130. /*
  131. ** Nuxt.js modules
  132. */
  133. modules: [
  134. // Doc: https://buefy.github.io/#/documentation
  135. [
  136. 'nuxt-buefy',
  137. {
  138. css: false,
  139. materialDesignIcons: false,
  140. defaultIconPack: 'trnd',
  141. defaultModalCanCancel: ['escape', 'button', 'outside'],
  142. defaultProgrammaticPromise: true,
  143. customIconPacks: {
  144. trnd: {
  145. sizes: {
  146. default: 'trnd-24px',
  147. 'is-small': null,
  148. 'is-medium': 'trnd-36px',
  149. 'is-large': 'trnd-48px'
  150. },
  151. iconPrefix: 'trnd-'
  152. }
  153. }
  154. }
  155. ],
  156. '@nuxtjs/eslint-module',
  157. 'nuxt-web3-provider'
  158. ],
  159. router: {
  160. linkActiveClass: '',
  161. linkExactActiveClass: 'is-active'
  162. },
  163. hooks: hooks(this),
  164. /*
  165. ** Build configuration
  166. */
  167. build: {
  168. /*
  169. ** You can extend webpack config here
  170. */
  171. extend(config, ctx) {
  172. if (ctx.isClient) {
  173. config.devtool = hasSourceMaps
  174. }
  175. config.module.rules.push({
  176. test: /\.bin$/,
  177. use: 'arraybuffer-loader'
  178. })
  179. },
  180. plugins: [
  181. new webpack.IgnorePlugin(/worker_threads/),
  182. new webpack.DefinePlugin({
  183. 'process.env': JSON.stringify({
  184. INFURA_KEY: process.env.INFURA_KEY,
  185. ALCHEMY_MAINNET_KEY: process.env.ALCHEMY_MAINNET_KEY,
  186. ALCHEMY_POLYGON_KEY: process.env.ALCHEMY_POLYGON_KEY,
  187. ALCHEMY_OPTIMISM_KEY: process.env.ALCHEMY_OPTIMISM_KEY,
  188. ALCHEMY_ARBITRUM_KEY: process.env.ALCHEMY_ARBITRUM_KEY,
  189. ALCHEMY_GOERLI_KEY: process.env.ALCHEMY_GOERLI_KEY,
  190. WC_BRIDGE: process.env.WC_BRIDGE,
  191. OLD_STORE_NAME: process.env.OLD_STORE_NAME,
  192. STORE_NAME: process.env.STORE_NAME,
  193. APP_ENS_NAME: process.env.APP_ENS_NAME
  194. })
  195. })
  196. ],
  197. html: {
  198. minify: {
  199. collapseWhitespace: true, // as @dario30186 mentioned
  200. removeComments: true // 👈 add this line
  201. }
  202. },
  203. loaders: {
  204. fontUrl: { limit: 25000 },
  205. imgUrl: { limit: 15000 }
  206. },
  207. splitChunks: {
  208. layouts: false,
  209. pages: false,
  210. commons: false
  211. }
  212. },
  213. buildModules: [
  214. [
  215. '@nuxtjs/moment',
  216. {
  217. defaultLocale: 'en',
  218. locales: ['ru', 'zh-cn', 'fr', 'es', 'tr', 'uk']
  219. }
  220. ]
  221. ],
  222. env: {
  223. commit: getCurrentCommit()
  224. },
  225. provider: {
  226. rpcUrl: `https://mainnet.infura.io/v3/${process.env.INFURA_KEY}`
  227. },
  228. // todo make custom loading page
  229. loadingIndicator: {
  230. name: 'circle',
  231. color: '#94febf',
  232. background: '#000'
  233. }
  234. }