{"ast":null,"code":"function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\n/* eslint-disable @typescript-eslint/no-var-requires */\nconst path = require('path');\n\nconst pkg = require('./package.json');\n\nconst publicPath = process.env.PUBLIC_PATH || '';\nconst apiUrl = process.env.API_URL || '/api';\nconst distDir = 'dist';\nconst APP = {\n  name: pkg.name,\n  version: pkg.version,\n  title: pkg.title,\n  description: pkg.description,\n  author: pkg.author,\n  keywords: pkg.keywords.join(',')\n};\nconst DEFAULT_LANGUAGE = 'en';\nconst LOCALE_PATH = 'public/locales';\nconst LANGUAGES = ['en', 'zh'];\nconst otherLanguages = LANGUAGES.filter(lang => lang !== DEFAULT_LANGUAGE);\nmodule.exports = {\n  target: 'serverless',\n  assetPrefix: publicPath,\n  distDir,\n  poweredByHeader: false,\n  env: _objectSpread({}, APP, {\n    DEFAULT_LANGUAGE,\n    LOCALE_PATH,\n    LANGUAGES,\n    PUBLIC_PATH: publicPath,\n    API_URL: apiUrl\n  }),\n  exportPathMap: defaultPathMap => _objectSpread({}, defaultPathMap, {}, Object.entries(defaultPathMap).reduce((prev, [path, router]) => {\n    otherLanguages.forEach(lang => prev[`/${lang}${path}`] = router);\n    return prev;\n  }, {})),\n  experimental: {\n    basePath: publicPath\n  },\n  webpack: (config, {\n    dev,\n    webpack\n  }) => {\n    const WorkerPlugin = require('worker-plugin');\n\n    config.output.webassemblyModuleFilename = 'static/wasm/[modulehash].wasm';\n    config.resolve = config.resolve || {};\n    config.resolve.alias = config.resolve.alias || {};\n    config.resolve.alias['~'] = path.resolve(__dirname);\n    config.node = Object.assign({}, config.node, {\n      // eslint-disable-next-line @typescript-eslint/camelcase\n      child_process: 'empty',\n      fs: 'empty'\n    });\n    config.plugins = [...(config.plugins || []), new WorkerPlugin({\n      globalObject: 'self'\n    })];\n\n    if (!dev || !!process.env.WITH_WASM) {\n      const WasmPackPlugin = require('@wasm-tool/wasm-pack-plugin');\n\n      config.plugins.push(new WasmPackPlugin({\n        crateDirectory: path.resolve(__dirname, 'wasm'),\n        outDir: 'dist',\n        outName: 'index'\n      }));\n    } else {\n      config.plugins.push(new webpack.IgnorePlugin(/^~\\/wasm\\//));\n    }\n\n    return config;\n  }\n};","map":null,"metadata":{},"sourceType":"script"}