diff --git a/now.json b/now.json index 49439d7248..65797e69c5 100644 --- a/now.json +++ b/now.json @@ -15,13 +15,17 @@ "src": "package.json", "use": "@now/static-build", "config": { - "distDir": "dist" + "distDir": "compiled" } + }, + { + "src": "resources/*", + "use": "@now/static" } ], "routes": [ { - "src": "/app/(.*).(js|icon|css)$", + "src": "/app/(.*).(js|icon|css|svg|png|gif|jpeg)$", "dest": "/$1.$2" }, { diff --git a/package.json b/package.json index 71dc33f654..e4d35e484e 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "start": "electron app/index.js", "lint": "eslint src/* --ext .ts,.tsx", "format": "prettier --write \"src/**/*\"", - "build": "rimraf compiled && env-cmd cross-env TS_NODE_PROJECT=\"tsconfig-webpack.json\" webpack --mode production --config webpack.production.conf.ts", + "build": "TS_NODE_PROJECT=\"tsconfig-webpack.json\" webpack --mode production", + "build:env": "rimraf compiled && env-cmd cross-env TS_NODE_PROJECT=\"tsconfig-webpack.json\" webpack --mode production", "meta": "node scripts/meta.js", "prepack": "rimraf dist && env-cmd npm run meta && electron-builder --dir", "pack": "rimraf dist && env-cmd npm run meta && electron-builder", diff --git a/webpack.config.ts b/webpack.config.ts index e2a8dce2d5..dfd5a57927 100644 --- a/webpack.config.ts +++ b/webpack.config.ts @@ -4,6 +4,7 @@ import HtmlWebpackPlugin from 'html-webpack-plugin' import express from 'express' import ErrorOverlayPlugin from 'error-overlay-webpack-plugin' import CopyPlugin from 'copy-webpack-plugin' +import TerserPlugin from 'terser-webpack-plugin' module.exports = (env, argv) => { const config = { @@ -16,12 +17,22 @@ module.exports = (env, argv) => { filename: 'bundle.js', // the output bundle - path: path.resolve(__dirname, 'compiled'), - publicPath: '' + path: path.resolve(__dirname, 'compiled') }, devtool: 'inline-source-map', + optimization: { + minimize: true, + minimizer: [ + new TerserPlugin({ + terserOptions: { + keep_fnames: /Block|Value|Bool|BooleanLiteral|Null|NullLiteral|Literal|NumberLiteral|StringLiteral|RegexLiteral|Arr|Obj|Op|Parens/ + } + }) + ] + }, + module: { rules: [ { @@ -121,7 +132,7 @@ module.exports = (env, argv) => { 'webpack-dev-server/client?http://localhost:3000', 'webpack/hot/only-dev-server' ) - config.output.publicPath = '/app' + ;(config.output as any).publicPath = '/app' } return config diff --git a/webpack.production.config.ts b/webpack.production.config.ts deleted file mode 100644 index b2f95a52e6..0000000000 --- a/webpack.production.config.ts +++ /dev/null @@ -1,92 +0,0 @@ -import path from 'path' -import webpack from 'webpack' -import HtmlWebpackPlugin from 'html-webpack-plugin' -import ErrorOverlayPlugin from 'error-overlay-webpack-plugin' -import CopyPlugin from 'copy-webpack-plugin' -import TerserPlugin from 'terser-webpack-plugin' - -module.exports = { - mode: 'production', - entry: [ - './src/index.tsx' - // the entry point of our app - ], - - output: { - filename: 'bundle.js', - // the output bundle - - path: path.resolve(__dirname, 'dist'), - - publicPath: '/app' - // necessary for HMR to know where to load the hot update chunks - }, - - optimization: { - minimize: true, - minimizer: [ - new TerserPlugin({ - terserOptions: { - keep_fnames: /Block|Value|Bool|BooleanLiteral|Null|NullLiteral|Literal|NumberLiteral|StringLiteral|RegexLiteral|Arr|Obj|Op|Parens/ - } - }) - ] - }, - - module: { - rules: [ - { - test: /\.css$/i, - use: ['style-loader', 'css-loader'] - }, - { - test: /\.(png|jpe?g|gif|svg|eot|ttf|woff|woff2)$/i, - loader: 'url-loader', - options: { - limit: 8192 - } - }, - { - test: /\.tsx?$/, - use: [{ loader: 'ts-loader' }], - exclude: /node_modules/ - }, - { - test: /\.md$/, - use: [ - { - loader: 'raw-loader' - } - ] - } - ] - }, - - plugins: [ - new webpack.NoEmitOnErrorsPlugin(), - // do not emit compiled assets that include errors - new HtmlWebpackPlugin(), - new ErrorOverlayPlugin(), - new webpack.EnvironmentPlugin([ - 'NODE_ENV', - 'AMPLIFY_AUTH_IDENTITY_POOL_ID', - 'AMPLIFY_AUTH_REGION', - 'AMPLIFY_PINPOINT_APPID', - 'AMPLIFY_PINPOINT_REGION', - 'BOOST_NOTE_BASE_URL' - ]), - new CopyPlugin([ - { - from: path.join(__dirname, 'node_modules/codemirror/theme'), - to: 'codemirror/theme' - } - ]) - ], - - resolve: { - extensions: ['.tsx', '.ts', '.js'] - }, - node: { - fs: 'empty' - } -}