Remove Firebase hosting, back to Express
This commit is contained in:
165
rollup.config.js
165
rollup.config.js
@ -11,6 +11,8 @@ const resolve = require('rollup-plugin-node-resolve');
|
||||
const url = require('rollup-plugin-url');
|
||||
|
||||
const entryManifest = require('./plugins/entryManifest');
|
||||
const pkg = require('./package.json');
|
||||
const secretKey = require('./secretKey');
|
||||
|
||||
const env = process.env.NODE_ENV || 'development';
|
||||
const dev = env === 'development';
|
||||
@ -59,70 +61,105 @@ const client = ['main', 'autoIndex'].map(entryName => {
|
||||
};
|
||||
});
|
||||
|
||||
const secretKey = require('./secretKey');
|
||||
const fnsPkg = require('./functions/package.json');
|
||||
|
||||
const fnsDeps = (dev
|
||||
? Object.keys(fnsPkg.dependencies).concat(
|
||||
Object.keys(fnsPkg.devDependencies || {})
|
||||
)
|
||||
: Object.keys(fnsPkg.dependencies)
|
||||
const dependencies = (dev
|
||||
? Object.keys(pkg.dependencies).concat(Object.keys(pkg.devDependencies || {}))
|
||||
: Object.keys(pkg.dependencies)
|
||||
).concat('react-dom/server');
|
||||
|
||||
const functions = [
|
||||
{
|
||||
external: id => true,
|
||||
input: path.resolve(__dirname, 'modules/functions/index.js'),
|
||||
output: { file: 'functions/index.js', format: 'cjs' },
|
||||
plugins: [
|
||||
babel(),
|
||||
json(),
|
||||
replace({
|
||||
'process.env.NODE_ENV': JSON.stringify(env)
|
||||
})
|
||||
]
|
||||
}
|
||||
].concat(
|
||||
[
|
||||
// 'serveAuth',
|
||||
'serveMainPage',
|
||||
'serveNpmPackageFile',
|
||||
'servePublicKey',
|
||||
'serveStats'
|
||||
].map(functionName => {
|
||||
return {
|
||||
external: builtinModules.concat(fnsDeps),
|
||||
input: path.resolve(__dirname, `modules/functions/${functionName}.js`),
|
||||
output: { file: `functions/${functionName}.js`, format: 'cjs' },
|
||||
plugins: [
|
||||
manifest.inject({ virtualId: 'entry-manifest' }),
|
||||
babel({ exclude: /node_modules/ }),
|
||||
json(),
|
||||
resolve(),
|
||||
commonjs(),
|
||||
url({
|
||||
limit: 5 * 1024,
|
||||
publicPath: '/_client/',
|
||||
emitFiles: false
|
||||
}),
|
||||
replace({
|
||||
'process.env.CLOUDFLARE_EMAIL': JSON.stringify(
|
||||
process.env.CLOUDFLARE_EMAIL
|
||||
),
|
||||
'process.env.CLOUDFLARE_KEY': JSON.stringify(
|
||||
process.env.CLOUDFLARE_KEY
|
||||
),
|
||||
'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
|
||||
'process.env.NODE_ENV': JSON.stringify(env),
|
||||
'process.env.NPM_REGISTRY_URL': JSON.stringify(
|
||||
process.env.NPM_REGISTRY_URL
|
||||
),
|
||||
'process.env.ORIGIN': JSON.stringify(process.env.ORIGIN),
|
||||
'process.env.SECRET_KEY': JSON.stringify(secretKey)
|
||||
})
|
||||
]
|
||||
};
|
||||
})
|
||||
);
|
||||
const server = {
|
||||
external: builtinModules.concat(dependencies),
|
||||
input: path.resolve(__dirname, 'modules/server.js'),
|
||||
output: { file: 'server.js', format: 'cjs' },
|
||||
plugins: [
|
||||
manifest.inject({ virtualId: 'entry-manifest' }),
|
||||
babel({ exclude: /node_modules/ }),
|
||||
json(),
|
||||
resolve(),
|
||||
commonjs(),
|
||||
url({
|
||||
limit: 5 * 1024,
|
||||
publicPath: '/_client/',
|
||||
emitFiles: false
|
||||
}),
|
||||
replace({
|
||||
'process.env.CLOUDFLARE_EMAIL': JSON.stringify(
|
||||
process.env.CLOUDFLARE_EMAIL
|
||||
),
|
||||
'process.env.CLOUDFLARE_KEY': JSON.stringify(process.env.CLOUDFLARE_KEY),
|
||||
'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
|
||||
'process.env.NODE_ENV': JSON.stringify(env),
|
||||
'process.env.NPM_REGISTRY_URL': JSON.stringify(
|
||||
process.env.NPM_REGISTRY_URL
|
||||
),
|
||||
'process.env.ORIGIN': JSON.stringify(process.env.ORIGIN),
|
||||
'process.env.SECRET_KEY': JSON.stringify(secretKey)
|
||||
})
|
||||
]
|
||||
};
|
||||
// const fnsPkg = require('./functions/package.json');
|
||||
|
||||
module.exports = client.concat(functions);
|
||||
// const fnsDeps = (dev
|
||||
// ? Object.keys(fnsPkg.dependencies).concat(
|
||||
// Object.keys(fnsPkg.devDependencies || {})
|
||||
// )
|
||||
// : Object.keys(fnsPkg.dependencies)
|
||||
// ).concat('react-dom/server');
|
||||
|
||||
// const functions = [
|
||||
// {
|
||||
// external: id => true,
|
||||
// input: path.resolve(__dirname, 'modules/functions/index.js'),
|
||||
// output: { file: 'functions/index.js', format: 'cjs' },
|
||||
// plugins: [
|
||||
// babel(),
|
||||
// json(),
|
||||
// replace({
|
||||
// 'process.env.NODE_ENV': JSON.stringify(env)
|
||||
// })
|
||||
// ]
|
||||
// }
|
||||
// ].concat(
|
||||
// [
|
||||
// // 'serveAuth',
|
||||
// 'serveMainPage',
|
||||
// 'serveNpmPackageFile',
|
||||
// 'servePublicKey',
|
||||
// 'serveStats'
|
||||
// ].map(functionName => {
|
||||
// return {
|
||||
// external: builtinModules.concat(fnsDeps),
|
||||
// input: path.resolve(__dirname, `modules/functions/${functionName}.js`),
|
||||
// output: { file: `functions/${functionName}.js`, format: 'cjs' },
|
||||
// plugins: [
|
||||
// manifest.inject({ virtualId: 'entry-manifest' }),
|
||||
// babel({ exclude: /node_modules/ }),
|
||||
// json(),
|
||||
// resolve(),
|
||||
// commonjs(),
|
||||
// url({
|
||||
// limit: 5 * 1024,
|
||||
// publicPath: '/_client/',
|
||||
// emitFiles: false
|
||||
// }),
|
||||
// replace({
|
||||
// 'process.env.CLOUDFLARE_EMAIL': JSON.stringify(
|
||||
// process.env.CLOUDFLARE_EMAIL
|
||||
// ),
|
||||
// 'process.env.CLOUDFLARE_KEY': JSON.stringify(
|
||||
// process.env.CLOUDFLARE_KEY
|
||||
// ),
|
||||
// 'process.env.DEBUG': JSON.stringify(process.env.DEBUG),
|
||||
// 'process.env.NODE_ENV': JSON.stringify(env),
|
||||
// 'process.env.NPM_REGISTRY_URL': JSON.stringify(
|
||||
// process.env.NPM_REGISTRY_URL
|
||||
// ),
|
||||
// 'process.env.ORIGIN': JSON.stringify(process.env.ORIGIN),
|
||||
// 'process.env.SECRET_KEY': JSON.stringify(secretKey)
|
||||
// })
|
||||
// ]
|
||||
// };
|
||||
// })
|
||||
// );
|
||||
|
||||
// module.exports = client.concat(functions);
|
||||
module.exports = client.concat(server);
|
||||
|
||||
Reference in New Issue
Block a user