diff --git a/package.json b/package.json index 321d8cc..a13ec8f 100644 --- a/package.json +++ b/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 ", "license": "MIT", diff --git a/webpack.config.js b/webpack.config.js index ae04305..563ebf5 100644 --- a/webpack.config.js +++ b/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'] diff --git a/webpack.config.web.js b/webpack.config.web.js index 3d4aa28..950c01a 100644 --- a/webpack.config.web.js +++ b/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']