diff --git a/.gitignore b/.gitignore index 9db9633..9dc2a0c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ node_modules dist wrangler.* -config.json \ No newline at end of file +config.json +config.prod.json \ No newline at end of file diff --git a/package.json b/package.json index 9008cc8..a4801b9 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "build": "webpack", "dev": "wrangler -c wrangler.dev.toml dev", "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" }, "author": "PeterCxy", diff --git a/src/index.coffee b/src/index.coffee index 8a79344..a86fce4 100644 --- a/src/index.coffee +++ b/src/index.coffee @@ -1,4 +1,4 @@ -import config from "../config.json" +import config from "config" import * as crypto from "./crypto" import S3 from "./aws/s3" diff --git a/webpack.config.js b/webpack.config.js index 7ad535b..dc559a9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,4 +1,5 @@ const path = require('path') +const { config } = require('process') module.exports = { entry: './src/index.coffee', @@ -10,6 +11,10 @@ module.exports = { resolve: { extensions: ['.coffee', '.js'], fallback: { "os": false }, + alias: { + config: path.resolve(__dirname, + process.env.NODE_ENV == "production" ? "config.prod.json" : "config.json") + } }, module: { rules: [