diff --git a/firebase.json b/firebase.json index 94da47eb90ad02cf5c1b8028ca3d43684b7f167e..a00223d4ddce6ed47ef14af8e3b78f86294c0706 100644 --- a/firebase.json +++ b/firebase.json @@ -1,7 +1,13 @@ { "hosting": { "public": "dist", - "rewrites": [{ "source": "/api/**", "function": "api" }], + "rewrites": [ + { "source": "/api/**", "function": "api" }, + { + "source": "**", + "destination": "/index.html" + } + ], "ignore": ["firebase.json", "**/.*", "**/node_modules/**"] } } diff --git a/functions/package.json b/functions/package.json index 5e142869dda3b8973da4ddb8b03c9d3d3e2f160e..aaa103a4ed9a0be3cc0c6dd8d01dfe2d6a33dfa6 100644 --- a/functions/package.json +++ b/functions/package.json @@ -2,12 +2,12 @@ "name": "functions", "description": "Cloud Functions for Firebase", "scripts": { - "serve": "npm run mock && firebase serve --only functions", + "serve": "firebase serve --only functions", "shell": "firebase functions:shell", "start": "npm run shell", "deploy": "firebase deploy --only functions", "logs": "firebase functions:log", - "mock": "cd .. && rollup -c" + "mock": "cd ../scripts && rollup -c" }, "dependencies": { "express": "^4.16.3", diff --git a/package.json b/package.json index b139bd538021d731d3bc68e73c21efc91db327ae..c870f38094ee913acd0361ddabd044c98314817c 100755 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "start": "cross-env ESLINT=none umi dev", "start:no-mock": "cross-env MOCK=none ESLINT=none umi dev", "build": "cross-env ESLINT=none umi build", - "site": "npm run presite && rollup -c && npm run build && firebase deploy", + "site": "npm run presite && npm run build && firebase deploy", "analyze": "cross-env ANALYZE=1 umi build", "lint:style": "stylelint \"src/**/*.less\" --syntax less", "lint": "eslint --ext .js src mock tests && npm run lint:style", diff --git a/scripts/all_mock.js b/scripts/all_mock.js index 095d4c6743359929bf4384192ec7daf5b92a0be6..98975684d319f6dda91d082de177d2cb1844021e 100644 --- a/scripts/all_mock.js +++ b/scripts/all_mock.js @@ -1,17 +1,33 @@ -import api from 'mock/api'; -import chart from 'mock/chart'; -import geographic from 'mock/geographic'; -import notices from 'mock/notices'; -import profile from 'mock/profile'; -import rule from 'mock/rule'; -import user from 'mock/user'; +import api from '../mock/api'; +import chart from '../mock/chart'; +import geographic from '../mock/geographic'; +import notices from '../mock/notices'; +import profile from '../mock/profile'; +import rule from '../mock/rule'; +import user from '../mock/user'; -export default { - ...api, - ...chart, - ...geographic, - ...notices, - ...profile, - ...rule, - ...user, -}; +const data = {}; +Object.keys(api).forEach(key => { + data[key] = api[key]; +}); +Object.keys(chart).forEach(key => { + data[key] = chart[key]; +}); + +Object.keys(geographic).forEach(key => { + data[key] = geographic[key]; +}); +Object.keys(notices).forEach(key => { + data[key] = notices[key]; +}); +Object.keys(profile).forEach(key => { + data[key] = profile[key]; +}); +Object.keys(rule).forEach(key => { + data[key] = rule[key]; +}); +Object.keys(user).forEach(key => { + data[key] = user[key]; +}); + +export default data; diff --git a/scripts/rollup.config.js b/scripts/rollup.config.js index dad0073d8b41e8c95f5227c2e4d8aca6f945ed77..98d49541b277b67697de4f52a2e8b04aee0a12c8 100644 --- a/scripts/rollup.config.js +++ b/scripts/rollup.config.js @@ -3,7 +3,7 @@ import json from 'rollup-plugin-json'; export default { input: './all_mock.js', output: { - file: './functions/mock/index.js', + file: '../functions/mock/index.js', format: 'umd', name: 'mock', },