Browse Source

support NODE_ENV

master
Peter Cai 3 years ago
parent
commit
10ef547da7
No known key found for this signature in database
GPG Key ID: 71F5FB4E4F3FD54F
  1. 2
      package.json
  2. 6
      webpack.config.js
  3. 5
      webpack.config.web.js

2
package.json

@ -9,7 +9,7 @@
"format": "prettier --write '**/*.{js,css,json,md}'",
"build-web": "webpack-cli --config webpack.config.web.js",
"build": "npm run build-web && wrangler build",
"preview": "npm run build-web && wrangler preview"
"preview": "NODE_ENV=development npm run build-web && wrangler preview"
},
"author": "Peter Cai <[email protected]>",
"license": "MIT",

6
webpack.config.js

@ -1,10 +1,12 @@
var process = require("process")
module.exports = {
target: "webworker",
entry: "./index.js",
mode: "production",
mode: "production", // CF Worker only works in production mode
optimization: {
// We no not want to minimize our code.
minimize: false
minimize: process.env.NODE_ENV == "production"
},
resolve: {
extensions: ['.js', '.coffee']

5
webpack.config.web.js

@ -1,18 +1,19 @@
var HtmlWebpackPlugin = require("html-webpack-plugin")
var HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin")
var path = require("path")
var process = require("process")
module.exports = {
target: "web",
entry: "./index-web.js",
mode: "development",
mode: process.env.NODE_ENV ? process.env.NODE_ENV : "development",
output: {
path: path.resolve(__dirname, "./worker"),
filename: "web.js"
},
optimization: {
// We no not want to minimize our code.
minimize: false
minimize: process.env.NODE_ENV == "production"
},
resolve: {
extensions: ['.js', '.coffee']

Loading…
Cancel
Save