Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: simplify development settings #583

Merged
merged 4 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/background/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(function() {
const script = document.createElement('script');
script.async = true;
script.src = (process.env.HOT)
script.src = (process.env.NODE_ENV)
? 'http://localhost:3000/dist/background.bundle.js'
: '../dist/background.bundle.js';
document.write(script.outerHTML);
Expand Down
2 changes: 1 addition & 1 deletion app/lib/loadThemes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Label is text that is shown in preferences theme selector
*/
export default () => {
const prefix = process.env.HOT ? 'http://localhost:3000/' : '../'
const prefix = process.env.NODE_ENV === 'development' ? 'http://localhost:3000/' : '../'
return [
{
value: `${prefix}dist/main/css/themes/light.css`,
Expand Down
5 changes: 3 additions & 2 deletions app/main/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<link rel='stylesheet' id='cerebro-theme'>
<script>
(function() {
if (!process.env.HOT) {
// NODE_ENV is undefined in production
if (!process.env.NODE_ENV) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = '../dist/main.css';
Expand All @@ -22,7 +23,7 @@
(function() {
const script = document.createElement('script');
script.async = true;
script.src = (process.env.HOT)
script.src = process.env.NODE_ENV === 'development'
? 'http://localhost:3000/dist/main.bundle.js'
: '../dist/main.bundle.js';
document.write(script.outerHTML);
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"dependencies": {
"move-file": "2.1.0",
"chokidar": "3.5.3",
"electron-updater": "5.0.1",
"electron-updater": "5.2.1",
"fix-path": "3.0.0",
"rimraf": "3.0.2",
"semver": "7.3.7"
Expand Down
48 changes: 34 additions & 14 deletions app/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ braces@~3.0.2:
dependencies:
fill-range "^7.0.1"

builder-util-runtime@9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-9.0.0.tgz#3a40ba7382712ccdb24471567f91d7c167e00830"
integrity sha512-SkpEtSmTkREDHRJnxKEv43aAYp8sYWY8fxYBhGLBLOBIRXeaIp6Kv3lBgSD7uR8jQtC7CA659sqJrpSV6zNvSA==
builder-util-runtime@9.0.3:
version "9.0.3"
resolved "https://registry.yarnpkg.com/builder-util-runtime/-/builder-util-runtime-9.0.3.tgz#6c62c493ba2b73c2af92432db4013b5a327f02b2"
integrity sha512-SfG2wnyjpUbbdtpnqDpWwklujofC6GarGpvdWrEkg9p5AD/xJmTF2buTNaqs3qtsNBEVQDDjZz9xc2GGpVyMfA==
dependencies:
debug "^4.3.2"
debug "^4.3.4"
sax "^1.2.4"

chokidar@3.5.3:
Expand Down Expand Up @@ -86,10 +86,10 @@ cross-spawn@^4.0.0:
lru-cache "^4.0.1"
which "^1.2.9"

debug@^4.3.2:
version "4.3.2"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.2.tgz#f0a49c18ac8779e31d4a0c6029dfb76873c7428b"
integrity sha512-mOp8wKcvj7XxC78zLgw/ZA+6TSgkoE2C/ienthhRD298T7UNwAg9diBpLRxC0mOezLl4B0xV7M0cCO6P/O0Xhw==
debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"

Expand All @@ -98,19 +98,20 @@ default-shell@^1.0.0:
resolved "https://registry.yarnpkg.com/default-shell/-/default-shell-1.0.1.tgz#752304bddc6174f49eb29cb988feea0b8813c8bc"
integrity sha512-/Os8tTMPSriNHCsVj3VLjMZblIl1sIg8EXz3qg7C5K+y9calfTA/qzlfPvCQ+LEgLWmtZ9wCnzE1w+S6TPPFyQ==

electron-updater@5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-5.0.1.tgz#327915f1b2e573daf1ce1d8102bcab93f4880c1a"
integrity sha512-dNnXPCqYmergXy3jgg4UICuD50Orug9GQe/5xfHy+BE2Fy0icB0QE+y6iQWdCDf7yeONxwMBf4HgIkGG5pIaVg==
electron-updater@5.2.1:
version "5.2.1"
resolved "https://registry.yarnpkg.com/electron-updater/-/electron-updater-5.2.1.tgz#297795e6e8ad9179c7ae2738a7b67cf0a5022be1"
integrity sha512-OQZVIvqcK8j03HjT07uVPgvguP/r8RY2wZcwCM26+fcDOjtrm01Dfz3G8Eru+69znbrR+F9pDzr98ewMavBrWQ==
dependencies:
"@types/semver" "^7.3.6"
builder-util-runtime "9.0.0"
builder-util-runtime "9.0.3"
fs-extra "^10.0.0"
js-yaml "^4.1.0"
lazy-val "^1.0.5"
lodash.escaperegexp "^4.1.2"
lodash.isequal "^4.5.0"
semver "^7.3.5"
typed-emitter "^2.1.0"

execa@^0.5.0:
version "0.5.1"
Expand Down Expand Up @@ -382,6 +383,13 @@ rimraf@3.0.2:
dependencies:
glob "^7.1.3"

rxjs@^7.5.2:
version "7.5.6"
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-7.5.6.tgz#0446577557862afd6903517ce7cae79ecb9662bc"
integrity sha512-dnyv2/YsXhnm461G+R/Pe5bWP41Nm6LBXEYWI6eiFP4fiwx6WRI/CD0zbdVAudd9xwLEF2IDcKXLHit0FYjUzw==
dependencies:
tslib "^2.1.0"

sax@^1.2.4:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
Expand Down Expand Up @@ -441,6 +449,18 @@ to-regex-range@^5.0.1:
dependencies:
is-number "^7.0.0"

tslib@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3"
integrity sha512-d6xOpEDfsi2CZVlPQzGeux8XMwLT9hssAsaPYExaQMuYskwb+x1x7J371tWlbBdWHroy99KnVB6qIkUbs5X3UQ==

typed-emitter@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/typed-emitter/-/typed-emitter-2.1.0.tgz#ca78e3d8ef1476f228f548d62e04e3d4d3fd77fb"
integrity sha512-g/KzbYKbH5C2vPkaXGu8DJlHrGKHLsM25Zg9WuC9pMGfuvT+X25tZQWo5fK1BjBm8+UrVE9LDCvaY0CQk+fXDA==
optionalDependencies:
rxjs "^7.5.2"

universalify@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/universalify/-/universalify-2.0.0.tgz#75a4984efedc4b08975c5aeb73f530d02df25717"
Expand Down
36 changes: 18 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"test-watch": "jest -- --watch",
"lint": "eslint app/background app/lib app/main app/plugins *.js",
"hot-server": "node -r @babel/register server.js",
"build-main": "cross-env NODE_ENV=production node -r @babel/register ./node_modules/webpack/bin/webpack --config webpack.config.electron.js --progress=profile --color",
"build-main-dev": "cross-env NODE_ENV=development node -r @babel/register ./node_modules/webpack/bin/webpack --config webpack.config.electron.js --progress=profile --color",
"build-renderer": "cross-env HOT=0 NODE_ENV=production node -r @babel/register ./node_modules/webpack/bin/webpack --config webpack.config.production.js --progress=profile --color",
"bundle-analyze": "cross-env ANALYZE=true NODE_ENV=production node -r @babel/register ./node_modules/webpack/bin/webpack --config webpack.config.production.js --progress=profile --color && open ./app/dist/stats.html",
"build-main": "webpack --mode production --config webpack.config.electron.js",
"build-main-dev": "webpack --mode development --config webpack.config.electron.js",
"build-renderer": "webpack --config webpack.config.production.js",
"bundle-analyze": "cross-env ANALYZE=true node ./node_modules/webpack/bin/webpack --config webpack.config.production.js && open ./app/dist/stats.html",
"build": "run-p build-main build-renderer",
"start": "cross-env NODE_ENV=production electron -r @babel/register ./app",
"start-hot": "yarn build-main-dev && cross-env HOT=1 NODE_ENV=development ./node_modules/.bin/electron -r @babel/register ./app",
"start": "cross-env NODE_ENV=production electron ./app",
"start-hot": "yarn build-main-dev && cross-env NODE_ENV=development electron ./app",
"release": "build -mwl --draft",
"dev": "run-p hot-server start-hot",
"postinstall": "electron-builder install-app-deps",
Expand Down Expand Up @@ -139,39 +139,39 @@
],
"homepage": "https://cerebroapp.com",
"devDependencies": {
"@babel/core": "7.18.5",
"@babel/eslint-parser": "7.18.2",
"@babel/preset-env": "7.18.2",
"@babel/preset-react": "7.17.12",
"@babel/register": "7.17.7",
"autoprefixer": "10.4.7",
"@babel/core": "7.18.13",
"@babel/eslint-parser": "7.18.9",
"@babel/preset-env": "7.18.10",
"@babel/preset-react": "7.18.6",
"@babel/register": "7.18.9",
"autoprefixer": "10.4.8",
"babel-loader": "8.2.5",
"copy-webpack-plugin": "6.4.0",
"cross-env": "7.0.3",
"css-loader": "5.2.7",
"electron": "19.0.4",
"electron": "19.0.14",
"electron-builder": "22.14.13",
"eslint": "8.18.0",
"eslint": "8.23.0",
"eslint-config-airbnb": "19.0.4",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-jest": "26.5.3",
"eslint-plugin-jest": "26.9.0",
"eslint-plugin-jsx-a11y": "6.5.1",
"eslint-plugin-react": "7.30.0",
"eslint-plugin-react": "7.31.1",
"eslint-plugin-react-hooks": "4.6.0",
"express": "4.18.1",
"jest": "27.5.1",
"lodash-webpack-plugin": "0.11.6",
"mini-css-extract-plugin": "1.6.2",
"npm-run-all": "4.1.5",
"postcss": "8.4.14",
"postcss": "8.4.16",
"postcss-loader": "4.2.0",
"postcss-nested": "5.0.6",
"style-loader": "2.0.0",
"url-loader": "4.1.1",
"webpack": "4.46.0",
"webpack-cli": "4.10.0",
"webpack-dev-middleware": "5.3.3",
"webpack-hot-middleware": "2.25.1",
"webpack-hot-middleware": "2.25.2",
"webpack-visualizer-plugin": "0.1.11"
},
"dependencies": {
Expand Down
8 changes: 1 addition & 7 deletions webpack.config.base.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const webpack = require('webpack')
const path = require('path')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin')
Expand All @@ -14,9 +13,7 @@ module.exports = {
rules: [{
test: /\.jsx?$/,
use: 'babel-loader',
exclude: modulePath => (
modulePath.match(/node_modules/) && !modulePath.match(/node_modules(\/|\\)cerebro-ui/)
)
exclude: /node_modules/
}, {
test: /\.jpe?g$|\.gif$|\.png$|\.svg$|\.woff$|\.ttf$|\.wav$|\.mp3$/,
use: ['url-loader']
Expand All @@ -36,9 +33,6 @@ module.exports = {
},
plugins: [
new LodashModuleReplacementPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
new CopyWebpackPlugin({
patterns: [{
from: 'app/main/css/themes/*',
Expand Down
17 changes: 2 additions & 15 deletions webpack.config.electron.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,21 @@
const webpack = require('webpack')
const baseConfig = require('./webpack.config.base')

const plugins = [
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(process.env.NODE_ENV)
}
})
]

module.exports = {
...baseConfig,
mode: process.env.NODE_ENV,
module: {
rules: [{
test: /\.jsx?$/,
exclude: /(node_modules)/,
exclude: /node_modules/,
use: ['babel-loader']
}]
},

plugins,

devtool: 'source-map',
entry: './app/main.development',

output: {
...baseConfig.output,
path: __dirname,
filename: './app/main.js'
filename: './main.js'
},

target: 'electron-main',
Expand Down
4 changes: 2 additions & 2 deletions webpack.config.production.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const path = require('path')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const baseConfig = require('./webpack.config.base')
const Visualizer = require('webpack-visualizer-plugin')
const baseConfig = require('./webpack.config.base')

const config = {
...baseConfig,

mode: process.env.NODE_ENV,
mode: 'production',

devtool: 'source-map',

Expand Down
Loading