switch config.json based on NODE_ENV

This commit is contained in:
Peter Cai 2021-11-24 17:58:38 -05:00
parent 4f06a2639e
commit b23d99ffe8
4 changed files with 9 additions and 3 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
node_modules node_modules
dist dist
wrangler.* wrangler.*
config.json config.json
config.prod.json

View File

@ -7,7 +7,7 @@
"build": "webpack", "build": "webpack",
"dev": "wrangler -c wrangler.dev.toml dev", "dev": "wrangler -c wrangler.dev.toml dev",
"publish-dev": "wrangler -c wrangler.dev.toml publish", "publish-dev": "wrangler -c wrangler.dev.toml publish",
"publish-prod": "wrangler -c wrangler.prod.toml publish", "publish-prod": "NODE_ENV=production wrangler -c wrangler.prod.toml publish",
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"author": "PeterCxy", "author": "PeterCxy",

View File

@ -1,4 +1,4 @@
import config from "../config.json" import config from "config"
import * as crypto from "./crypto" import * as crypto from "./crypto"
import S3 from "./aws/s3" import S3 from "./aws/s3"

View File

@ -1,4 +1,5 @@
const path = require('path') const path = require('path')
const { config } = require('process')
module.exports = { module.exports = {
entry: './src/index.coffee', entry: './src/index.coffee',
@ -10,6 +11,10 @@ module.exports = {
resolve: { resolve: {
extensions: ['.coffee', '.js'], extensions: ['.coffee', '.js'],
fallback: { "os": false }, fallback: { "os": false },
alias: {
config: path.resolve(__dirname,
process.env.NODE_ENV == "production" ? "config.prod.json" : "config.json")
}
}, },
module: { module: {
rules: [ rules: [