Skip to content

Commit

Permalink
modify toolchain config to prepare for using react
Browse files Browse the repository at this point in the history
lihsai0 committed Oct 17, 2022
1 parent 3e46716 commit b16952f
Showing 16 changed files with 967 additions and 138 deletions.
11 changes: 11 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
max_line_length = 120
tab_width = 2
trim_trailing_whitespace = true
30 changes: 18 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kodo-browser",
"version": "1.0.19.2",
"version": "1.0.20-alpha",
"license": "Apache-2.0",
"author": {
"name": "Rong Zhou",
@@ -48,7 +48,7 @@
}
},
"engines": {
"node": ">=12.0.0 <13.0.0"
"node": "^14 || ^16"
},
"devDependencies": {
"@babel/core": "^7.1.6",
@@ -57,14 +57,14 @@
"@types/jest": "^27.0.2",
"@types/lodash": "^4.14.182",
"@types/mock-fs": "^4.13.1",
"@types/react-dom": "^18.0.6",
"archiver": "^3.0.3",
"copy-webpack-plugin": "^9.0.1",
"cross-env": "^5.2.0",
"css-loader": "^5.2.7",
"electron-builder": "^20.34.0",
"electron-installer-dmg": "^3.0.0",
"electron-packager": "^14.1.0",
"font-awesome": "^4.7.0",
"gulp": "^4.0.0",
"gulp-connect": "^5.7.0",
"gulp-load-plugins": "^2.0.7",
@@ -77,6 +77,11 @@
"mock-fs": "^5.1.1",
"npm": "^6.13.4",
"npm-run-all": "^4.1.3",
"postcss": "^8.4.5",
"postcss-loader": "^7.0.1",
"postcss-preset-env": "^7.2.3",
"sass": "^1.54.2",
"sass-loader": "^13.0.2",
"source-map-loader": "^3.0.1",
"ts-jest": "^27.0.7",
"ts-loader": "^9.2.6",
@@ -87,30 +92,31 @@
"dependencies": {
"@electron/remote": "^2.0.8",
"@root/walk": "^1.1.0",
"@uirouter/angularjs": "^1.0.20",
"angular": "1.7.9",
"angular-sanitize": "1.7.5",
"angular-translate": "^2.18.1",
"angular-ui-bootstrap": "^2.5.6",
"bootstrap": "^3.4.1",
"bootstrap-table": "^1.12.1",
"bootstrap": "^5.1.3",
"bootstrap-icons": "^1.8.1",
"classnames": "^2.3.1",
"clipboard": "^2.0.4",
"codemirror": "^5.41.0",
"crc32-stream": "^4.0.2",
"csv-stringify": "^5.3.6",
"downloads-folder": "1.0.3",
"electron": "18.3.3",
"events": "^2.0.0",
"font-awesome": "^4.7.0",
"form-data": "^4.0.0",
"jquery": "^3.5.1",
"jquery.qrcode": "^1.0.3",
"js-base64": "^3.4.5",
"js-md5": "^0.7.3",
"kodo-s3-adapter-sdk": "0.2.35",
"lodash": "^4.17.21",
"mime": "^2.3.1",
"moment": "^2.22.2",
"qiniu-path": "^0.0.3",
"react": "^18.2.0",
"react-bootstrap": "^2.1.1",
"react-dom": "^18.2.0",
"react-hook-form": "^7.27.1",
"react-hot-toast": "^2.2.0",
"react-router-dom": "^6.3.0",
"request": "^2.88.0",
"sanitize-filename": "^1.6.1",
"semaphore-promise": "^1.2.0",
10 changes: 10 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
module.exports = {
plugins: [
require("postcss-preset-env")({
features: {
'nesting-rules': true,
},
autoprefixer: false,
}),
],
};
File renamed without changes
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
9 changes: 7 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -23,6 +23,9 @@
"baseUrl": "src",
"paths": {
"@/*": [
"./*"
],
"@renderer/*": [
"renderer/*"
],
"@common/*": [
@@ -31,11 +34,13 @@
},
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"sourceMap": true
"sourceMap": true,
"jsx": "react"
},
"exclude": [
"node_modules",
"dist",
"build"
"build",
"src/renderer-ng"
]
}
3 changes: 1 addition & 2 deletions webpack/paths.js
Original file line number Diff line number Diff line change
@@ -34,8 +34,7 @@ module.exports = {

appRenderer: resolveApp('src/renderer'),
appBuildRenderer: resolveApp('dist/renderer'),
appRendererIndex: resolveApp('src/renderer/index.js'),
appRendererTemplateMappings: resolveApp('src/renderer/app-module/templates/url-tpl-mappings'),
appRendererIndex: resolveApp('src/renderer/index.tsx'),
appRendererComponents: resolveApp('src/renderer/components'),
appRendererCopies: copies.map(resolveApp)
}
29 changes: 15 additions & 14 deletions webpack/webpack-main.config.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
// main config
const paths = require('./paths')
const paths = require("./paths");

module.exports = function(webpackEnv) {
const isEnvDevelopment = webpackEnv.development
const isEnvProduction = webpackEnv.production
const isEnvDevelopment = webpackEnv.development;
const isEnvProduction = webpackEnv.production;

return {
target: 'electron-main',
mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
target: "electron-main",
mode: isEnvProduction ? "production" : isEnvDevelopment && "development",
resolve: {
alias: {
'@common': paths.appCommon,
"@common": paths.appCommon,
"@main": paths.appMain,
},
extensions: ['.ts', '.js'],
extensions: [".ts", ".js"],
},
entry: {
main: paths.appMainIndex,
downloader: paths.appMainDownloader,
uploader: paths.appMainUploader,
},
output: {
filename: '[name]-bundle.js',
filename: "[name]-bundle.js",
chunkFilename: isEnvProduction
? '[name].chunk.[chunkhash:8].js'
: isEnvDevelopment && '[name].chunk.js',
? "[name].chunk.[chunkhash:8].js"
: isEnvDevelopment && "[name].chunk.js",
path: paths.appBuildMain,
clean: true,
},
@@ -37,14 +38,14 @@ module.exports = function(webpackEnv) {
chunks: "all",
cacheGroups: {
libs: {
name: 'chunk-libs',
name: "chunk-libs",
test: /[\\/]node_modules[\\/]/,
priority: 20,
chunks: 'initial' // only package third parties that are initially dependent
chunks: "initial", // only package third parties that are initially dependent
},
},
},
minimize: isEnvProduction,
},
}
}
};
};
106 changes: 68 additions & 38 deletions webpack/webpack-renderer.config.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
const path = require('path')
// Node.JS package
const path = require("path");

const HtmlWebpackPlugin = require('html-webpack-plugin')
const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
// Webpack package
const HtmlWebpackPlugin = require("html-webpack-plugin");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");

const paths = require('./paths')
// project package
const paths = require("./paths");

module.exports = function(webpackEnv) {
const isEnvDevelopment = webpackEnv.development
const isEnvProduction = webpackEnv.production
const shouldUseSourceMap = webpackEnv.sourcemap
const isEnvDevelopment = webpackEnv.development;
const isEnvProduction = webpackEnv.production;
const shouldUseSourceMap = webpackEnv.sourcemap;

return {
devtool: isEnvProduction
? shouldUseSourceMap
? 'source-map'
: false
: isEnvDevelopment && 'eval-source-map',
target: 'electron-renderer',
mode: isEnvProduction ? 'production' : isEnvDevelopment && 'development',
? shouldUseSourceMap
? "source-map"
: false
: isEnvDevelopment && "source-map",
target: "electron-renderer",
mode: isEnvProduction ? "production" : isEnvDevelopment && "development",
resolve: {
alias: {
'@': paths.appRenderer,
'@common': paths.appCommon,
'@template-mappings': paths.appRendererTemplateMappings,
"@": paths.appSrc,
"@common": paths.appCommon,
"@renderer": paths.appRenderer,
},
extensions: ['.ts', '.js'],
extensions: [".ts", ".tsx", ".js"],
aliasFields: [],
mainFields: ['module', 'main'],
},
@@ -36,20 +39,20 @@ module.exports = function(webpackEnv) {
path: paths.appBuildRenderer,
pathinfo: isEnvDevelopment,
filename: isEnvProduction
? '[name].[chunkhash:8].js'
: isEnvDevelopment && '[name].js',
? "[name].[chunkhash:8].js"
: isEnvDevelopment && "[name].js",
chunkFilename: isEnvProduction
? '[name].chunk.[chunkhash:8].js'
: isEnvDevelopment && '[name].chunk.js',
? "[name].chunk.[chunkhash:8].js"
: isEnvDevelopment && "[name].chunk.js",
clean: true,
},
plugins: [
...paths.appPages.map(
pagePath =>
new HtmlWebpackPlugin({
template: pagePath,
inject: false,
})
pagePath =>
new HtmlWebpackPlugin({
template: pagePath,
inject: false,
})
),
new MiniCssExtractPlugin(),
new CopyWebpackPlugin({
@@ -72,10 +75,37 @@ module.exports = function(webpackEnv) {
enforce: "pre",
use: ["source-map-loader"],
},
{ test: /\.ts$/, loader: "ts-loader" },
{ test: /\.tsx?$/, loader: "ts-loader" },
{
test: /\.css$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader'],
use: [
MiniCssExtractPlugin.loader,
"css-loader",
],
},
{
test: /\.s[ac]ss$/i,
use: [
MiniCssExtractPlugin.loader,
{
loader: "css-loader",
options: {
sourceMap: true,
},
},
{
loader: "postcss-loader",
options: {
sourceMap: true,
},
},
{
loader: "sass-loader",
options: {
sourceMap: true,
},
},
],
},
{
test: /\.html$/i,
@@ -92,14 +122,14 @@ module.exports = function(webpackEnv) {
},
{
test: /\.(png|svg|jpg|jpeg|gif)$/i,
type: 'asset/resource',
type: "asset/resource",
generator: {
filename: "static/images/[name][ext]",
},
},
{
test: /\.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset/resource',
type: "asset/resource",
generator: {
filename: "static/fonts/[name][ext]",
},
@@ -111,29 +141,29 @@ module.exports = function(webpackEnv) {
chunks: "all",
cacheGroups: {
libs: {
name: 'chunk-libs',
name: "chunk-libs",
test: /[\\/]node_modules[\\/]/,
priority: 20,
chunks: 'initial' // only package third parties that are initially dependent
chunks: "initial", // only package third parties that are initially dependent
},
templates: {
name: 'chunk-templates',
name: "chunk-templates",
test: /\.html$/i,
priority: 10,
minChunks: 1,
},
components: {
name: 'chunk-components',
name: "chunk-components",
test: paths.appRendererComponents,
priority: 5,
minChunks: 2,
},
}
},
},
minimize: isEnvProduction,
},
ignoreWarnings: [
/Failed to parse source map/,
],
}
}
};
};
907 changes: 837 additions & 70 deletions yarn.lock

Large diffs are not rendered by default.

0 comments on commit b16952f

Please sign in to comment.