catalyst-core 0.0.1-beta.2 → 0.0.1-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -13
- package/bin/catalyst.js +2 -3
- package/config.json +0 -1
- package/{LICENSE → license} +2 -1
- package/{logger/index.js → logger.js} +10 -10
- package/package.json +17 -19
- package/packages/create-framework-app/templates/redux-js/node_modules/catalyst/src/router.js +1 -0
- package/router/ClientRouter.js +10 -6
- package/router/ServerRouter.js +2 -11
- package/scripts/build.js +10 -4
- package/scripts/checkVersion.js +5 -0
- package/scripts/loadEnvironmentVariables.js +8 -21
- package/scripts/loadScriptsBeforeServerStarts.js +12 -20
- package/scripts/serve.js +11 -4
- package/scripts/start.js +2 -4
- package/scripts/validator.js +40 -11
- package/server/expressServer.js +50 -0
- package/server/renderer/document/Body.js +17 -18
- package/server/renderer/document/Head.js +6 -7
- package/server/renderer/document/index.js +2 -0
- package/server/renderer/extract.js +25 -24
- package/server/renderer/handler.js +212 -188
- package/server/renderer/index.js +6 -7
- package/server/renderer/render.js +21 -19
- package/server/startServer.js +65 -0
- package/server/utils/userAgentUtil.js +55 -0
- package/server/utils/validator.js +40 -10
- package/webpack/babel-plugins/remove-client.plugin.js +1 -1
- package/webpack/babel-plugins/remove-ssr.plugin.js +1 -1
- package/webpack/babel.config.client.js +2 -2
- package/webpack/base.babel.js +29 -36
- package/webpack/development.client.babel.js +11 -8
- package/webpack/production.client.babel.js +1 -2
- package/webpack/production.ssr.babel.js +3 -3
- package/webpack/scssParams.js +19 -15
- package/.prettierignore +0 -2
- package/.prettierrc.json +0 -7
- package/checkVersion.js +0 -3
- package/config/config.js +0 -24
- package/packages/create-framework-app/node_modules/.package-lock.json +0 -249
- package/reducer/index.js +0 -88
- package/reducer/loadableConfigReducer.js +0 -19
- package/store/index.dev.js +0 -73
- package/store/index.js +0 -25
- package/store/index.prod.js +0 -66
|
@@ -7,7 +7,7 @@ const handleError = e => {
|
|
|
7
7
|
const validatePreInitServer = fn => {
|
|
8
8
|
try {
|
|
9
9
|
if (!fn) throw new Error("preServerInit named function should be defined in server/index.js");
|
|
10
|
-
if (typeof fn !==
|
|
10
|
+
if (typeof fn !== "function") throw new Error("preServerInit should be function present in server/index.js");
|
|
11
11
|
return true;
|
|
12
12
|
} catch (e) {
|
|
13
13
|
handleError(e);
|
|
@@ -16,7 +16,7 @@ const validatePreInitServer = fn => {
|
|
|
16
16
|
const validateMiddleware = fn => {
|
|
17
17
|
try {
|
|
18
18
|
if (!fn) throw new Error("addMiddlewares named function not found in server/server.js");
|
|
19
|
-
if (typeof fn !==
|
|
19
|
+
if (typeof fn !== "function") throw new Error("addMiddlewares should be function present in server/server.js");
|
|
20
20
|
return true;
|
|
21
21
|
} catch (e) {
|
|
22
22
|
handleError(e);
|
|
@@ -25,7 +25,7 @@ const validateMiddleware = fn => {
|
|
|
25
25
|
const validateReducerFunction = fn => {
|
|
26
26
|
try {
|
|
27
27
|
if (!fn) throw new Error("reducer not found in src/js/containers/App/reducer");
|
|
28
|
-
if (typeof fn !==
|
|
28
|
+
if (typeof fn !== "function") throw new Error("reducer should present in src/js/containers/App/reducer");
|
|
29
29
|
return true;
|
|
30
30
|
} catch (e) {
|
|
31
31
|
handleError(e);
|
|
@@ -34,7 +34,24 @@ const validateReducerFunction = fn => {
|
|
|
34
34
|
const validateConfigFile = obj => {
|
|
35
35
|
try {
|
|
36
36
|
if (!obj) throw new Error("config not found in config folder");
|
|
37
|
-
if (typeof obj !==
|
|
37
|
+
if (typeof obj !== "object") throw new Error("config object should be exported from config folder inside your project root directory");
|
|
38
|
+
if (typeof obj === "object") {
|
|
39
|
+
const requiredConfigKeys = {
|
|
40
|
+
NODE_SERVER_HOSTNAME: "",
|
|
41
|
+
NODE_SERVER_PORT: "",
|
|
42
|
+
WEBPACK_DEV_SERVER_HOSTNAME: "",
|
|
43
|
+
WEBPACK_DEV_SERVER_PORT: "",
|
|
44
|
+
BUILD_OUTPUT_PATH: "",
|
|
45
|
+
PUBLIC_STATIC_ASSET_PATH: "",
|
|
46
|
+
PUBLIC_STATIC_ASSET_URL: "",
|
|
47
|
+
NODE_ENV: "",
|
|
48
|
+
CLIENT_ENV_VARIABLES: [],
|
|
49
|
+
ANALYZE_BUNDLE: ""
|
|
50
|
+
};
|
|
51
|
+
for (let key in requiredConfigKeys) {
|
|
52
|
+
if (!(key in obj)) throw new Error(`${key} key not found inside config.json`);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
38
55
|
return true;
|
|
39
56
|
} catch (e) {
|
|
40
57
|
handleError(e);
|
|
@@ -43,7 +60,7 @@ const validateConfigFile = obj => {
|
|
|
43
60
|
const validatePackageJson = obj => {
|
|
44
61
|
try {
|
|
45
62
|
if (!obj) throw new Error("package.json not found in the project");
|
|
46
|
-
if (typeof obj !==
|
|
63
|
+
if (typeof obj !== "object") throw new Error("package.json should be defined in project root directory");
|
|
47
64
|
return true;
|
|
48
65
|
} catch (e) {
|
|
49
66
|
handleError(e);
|
|
@@ -52,7 +69,20 @@ const validatePackageJson = obj => {
|
|
|
52
69
|
const validateModuleAlias = obj => {
|
|
53
70
|
try {
|
|
54
71
|
if (!obj) throw new Error("moduleAliases not found in package.json file present in root directory.");
|
|
55
|
-
if (typeof obj !==
|
|
72
|
+
if (typeof obj !== "object") throw new Error("moduleAliases named object should be exported from package.json");
|
|
73
|
+
if (typeof obj === "object") {
|
|
74
|
+
const requiredModuleAliases = {
|
|
75
|
+
"@api": "api.js",
|
|
76
|
+
"@containers": "src/js/containers",
|
|
77
|
+
"@server": "server",
|
|
78
|
+
"@config": "config",
|
|
79
|
+
"@css": "src/static/css",
|
|
80
|
+
"@routes": "src/js/routes/"
|
|
81
|
+
};
|
|
82
|
+
for (let key in requiredModuleAliases) {
|
|
83
|
+
if (!(key in obj)) throw new Error(`${key} module alias not defined inside package.json`);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
56
86
|
return true;
|
|
57
87
|
} catch (e) {
|
|
58
88
|
handleError(e);
|
|
@@ -61,7 +91,7 @@ const validateModuleAlias = obj => {
|
|
|
61
91
|
const validateConfigureStore = fn => {
|
|
62
92
|
try {
|
|
63
93
|
if (!fn) throw new Error("configureStore not found in file src/js/store/index.js");
|
|
64
|
-
if (typeof fn !==
|
|
94
|
+
if (typeof fn !== "function") throw new Error("configureStore should be function exported from src/js/store/index.js");
|
|
65
95
|
return true;
|
|
66
96
|
} catch (e) {
|
|
67
97
|
handleError(e);
|
|
@@ -69,8 +99,8 @@ const validateConfigureStore = fn => {
|
|
|
69
99
|
};
|
|
70
100
|
const validateGetRoutes = fn => {
|
|
71
101
|
try {
|
|
72
|
-
if (!fn) throw new Error("getRoutes not found in file src/js/
|
|
73
|
-
if (typeof fn !==
|
|
102
|
+
if (!fn) throw new Error("getRoutes not found in file src/js/routes/utils.js");
|
|
103
|
+
if (typeof fn !== "function") throw new Error("getRoutes should be function exported from src/js/routers/index.js");
|
|
74
104
|
return true;
|
|
75
105
|
} catch (e) {
|
|
76
106
|
handleError(e);
|
|
@@ -79,7 +109,7 @@ const validateGetRoutes = fn => {
|
|
|
79
109
|
const validateCustomDocument = fn => {
|
|
80
110
|
try {
|
|
81
111
|
if (!fn) throw new Error("document not found in file server/document.js");
|
|
82
|
-
if (typeof fn !==
|
|
112
|
+
if (typeof fn !== "function") throw new Error("document should be a react component exported from server/document.js");
|
|
83
113
|
return true;
|
|
84
114
|
} catch (e) {
|
|
85
115
|
handleError(e);
|
|
@@ -16,8 +16,8 @@ var _default = exports.default = {
|
|
|
16
16
|
production: {
|
|
17
17
|
plugins: [require("./babel-plugins/remove-ssr.plugin").default, "transform-react-remove-prop-types"]
|
|
18
18
|
},
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
test: {
|
|
20
|
+
presets: ["@babel/preset-react"]
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
ignore: ["__TEST__"]
|
package/webpack/base.babel.js
CHANGED
|
@@ -16,14 +16,14 @@ var _loadEnvironmentVariables = _interopRequireDefault(require("../scripts/loadE
|
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
const catalystConfig = require(_path.default.resolve(__dirname, "..", "config.json"));
|
|
18
18
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} = require(`${process.env.src_path}/config`);
|
|
19
|
+
CLIENT_ENV_VARIABLES: clientEnv,
|
|
20
|
+
ANALYZE_BUNDLE
|
|
21
|
+
} = require(`${process.env.src_path}/config/config.json`);
|
|
22
22
|
const {
|
|
23
23
|
_moduleAliases
|
|
24
24
|
} = require(`${process.env.src_path}/package.json`);
|
|
25
25
|
(0, _loadEnvironmentVariables.default)();
|
|
26
|
-
const isDev = process.env.NODE_ENV
|
|
26
|
+
const isDev = process.env.NODE_ENV === "development";
|
|
27
27
|
const isSSR = !!process.env.SSR || false;
|
|
28
28
|
const basePlugins = exports.basePlugins = [new _webpackPlugin.default({
|
|
29
29
|
filename: "loadable-stats.json",
|
|
@@ -36,45 +36,45 @@ new _webpack.default.DefinePlugin({
|
|
|
36
36
|
"process.env": ([...clientEnv, ...Object.keys(process.env)] || []).reduce((clientEnvMap, env) => {
|
|
37
37
|
clientEnvMap[env] = JSON.stringify(process.env[env]);
|
|
38
38
|
return clientEnvMap;
|
|
39
|
-
}, {})
|
|
40
|
-
// Loadable dynamic rendring config
|
|
41
|
-
"process.loadableConfig": {
|
|
42
|
-
CLIENT_ONLY_RENDER: process.env["CLIENT_ONLY_RENDER"] === "true",
|
|
43
|
-
SERVER_SIDE_RENDER: process.env["SERVER_SIDE_RENDER"] === "true"
|
|
44
|
-
}
|
|
39
|
+
}, {})
|
|
45
40
|
}),
|
|
46
41
|
// ** This is used to analyze bundle size.
|
|
47
|
-
|
|
48
|
-
generateStatsFile:
|
|
42
|
+
ANALYZE_BUNDLE && new _webpackBundleAnalyzer.BundleAnalyzerPlugin({
|
|
43
|
+
generateStatsFile: ANALYZE_BUNDLE
|
|
49
44
|
}), new _webpack.default.IgnorePlugin({
|
|
50
45
|
resourceRegExp: /^\.\/locale$/,
|
|
51
46
|
contextRegExp: /moment$/
|
|
52
47
|
})];
|
|
53
|
-
|
|
48
|
+
const {
|
|
49
|
+
PUBLIC_STATIC_ASSET_URL,
|
|
50
|
+
PUBLIC_STATIC_ASSET_PATH,
|
|
51
|
+
WEBPACK_DEV_SERVER_HOSTNAME,
|
|
52
|
+
WEBPACK_DEV_SERVER_PORT
|
|
53
|
+
} = process.env;
|
|
54
|
+
let publicPath = isDev ? `http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/` : `${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;
|
|
54
55
|
var _default = exports.default = {
|
|
55
56
|
context: _path.default.resolve(process.env.src_path),
|
|
56
57
|
mode: isDev ? "development" : "production",
|
|
57
58
|
entry: {
|
|
58
59
|
app: [_path.default.resolve(process.env.src_path, "./client/index.js")]
|
|
59
60
|
},
|
|
60
|
-
// TODO this will be moved each config
|
|
61
|
-
|
|
62
61
|
output: {
|
|
63
|
-
path: _path.default.join(process.env.src_path, process.env.
|
|
64
|
-
|
|
62
|
+
path: _path.default.join(process.env.src_path, `${process.env.BUILD_OUTPUT_PATH}/public`),
|
|
63
|
+
chunkFilename: process.env.NODE_ENV === "development" ? catalystConfig.chunkFileNameDev : catalystConfig.chunkFileNameProd,
|
|
65
64
|
publicPath: publicPath,
|
|
66
|
-
chunkFilename:
|
|
65
|
+
chunkFilename: process.env.NODE_ENV === "development" ? catalystConfig.chunkFileNameDev : catalystConfig.chunkFileNameProd
|
|
67
66
|
},
|
|
68
67
|
resolve: {
|
|
68
|
+
fallback: {
|
|
69
|
+
url: require.resolve("url")
|
|
70
|
+
},
|
|
69
71
|
extensions: [".js", ".jsx", ".scss"],
|
|
70
72
|
alias: Object.keys(_moduleAliases || {}).reduce((moduleEnvMap, alias) => {
|
|
71
73
|
moduleEnvMap[alias] = _path.default.join(process.env.src_path, ..._moduleAliases[alias].split("/"));
|
|
72
74
|
return moduleEnvMap;
|
|
73
75
|
}, {})
|
|
74
76
|
},
|
|
75
|
-
// TODO common plugins here. Rest will be moved to each file
|
|
76
77
|
plugins: basePlugins,
|
|
77
|
-
// TODO module rules will be here. and should be common for all
|
|
78
78
|
module: {
|
|
79
79
|
rules: [{
|
|
80
80
|
test: /\.jsx$|\.js$/,
|
|
@@ -84,9 +84,7 @@ var _default = exports.default = {
|
|
|
84
84
|
options: isSSR ? _babelConfig2.default : _babelConfig.default
|
|
85
85
|
}
|
|
86
86
|
}, {
|
|
87
|
-
//
|
|
88
|
-
// anything inside node_modules and everything inside src/css/base
|
|
89
|
-
// since they should be globally scoped.
|
|
87
|
+
// This loader processes all the .scss files that should be modularized. This should exclude anything inside node_modules and everything inside src/css/base since they should be globally scoped.
|
|
90
88
|
test: /\.scss$/,
|
|
91
89
|
exclude: [_path.default.resolve(process.env.src_path, "./node_modules"), _path.default.resolve(process.env.src_path, "./src/static/css/base")],
|
|
92
90
|
use: [isDev && "css-hot-loader", !isSSR && _miniCssExtractPlugin.default.loader, {
|
|
@@ -96,15 +94,14 @@ var _default = exports.default = {
|
|
|
96
94
|
mode: "local",
|
|
97
95
|
exportOnlyLocals: !isDev && isSSR,
|
|
98
96
|
localIdentName: isDev ? catalystConfig.cssModulesIdentifierDev : catalystConfig.cssModulesIdentifierProd
|
|
99
|
-
}
|
|
100
|
-
importLoaders: 0
|
|
97
|
+
}
|
|
101
98
|
}
|
|
102
99
|
}, {
|
|
103
100
|
loader: "postcss-loader"
|
|
104
101
|
}, {
|
|
105
102
|
loader: "sass-loader",
|
|
106
103
|
options: {
|
|
107
|
-
additionalData: "$font_url: " + (0, _scssParams.fontUrl)() + ";" + "$url_for: " + (0, _scssParams.
|
|
104
|
+
additionalData: "$font_url: " + (0, _scssParams.fontUrl)() + ";" + "$url_for: " + (0, _scssParams.imageUrl)() + ";"
|
|
108
105
|
}
|
|
109
106
|
}, {
|
|
110
107
|
loader: "sass-resources-loader",
|
|
@@ -113,19 +110,17 @@ var _default = exports.default = {
|
|
|
113
110
|
}
|
|
114
111
|
}]
|
|
115
112
|
}, {
|
|
116
|
-
//
|
|
117
|
-
// for .scss modules that need to be available globally, we don't pass
|
|
118
|
-
// the files through css-loader to be modularized.
|
|
113
|
+
// In development mode, client request app.css ,which has all the css in node_modules and src/static/css/base, This is served by webpack-dev-server. However in prod this css is injected in the doc sent from the server and needs to be global, so we don't pass the files through css-loader to be modularized.
|
|
119
114
|
test: /\.scss$/,
|
|
120
115
|
include: [_path.default.resolve(process.env.src_path, "./node_modules"), _path.default.resolve(process.env.src_path, "./src/static/css/base")],
|
|
121
|
-
use: ["css-hot-loader", !isSSR && _miniCssExtractPlugin.default.loader, {
|
|
116
|
+
use: [isDev && "css-hot-loader", !isSSR && _miniCssExtractPlugin.default.loader, {
|
|
122
117
|
loader: "css-loader"
|
|
123
118
|
}, {
|
|
124
119
|
loader: "postcss-loader"
|
|
125
120
|
}, {
|
|
126
121
|
loader: "sass-loader",
|
|
127
122
|
options: {
|
|
128
|
-
additionalData: "$font_url: " + (0, _scssParams.fontUrl)() + ";" + "$url_for: " + (0, _scssParams.
|
|
123
|
+
additionalData: "$font_url: " + (0, _scssParams.fontUrl)() + ";" + "$url_for: " + (0, _scssParams.imageUrl)() + ";"
|
|
129
124
|
}
|
|
130
125
|
}, {
|
|
131
126
|
loader: "sass-resources-loader",
|
|
@@ -136,9 +131,7 @@ var _default = exports.default = {
|
|
|
136
131
|
}, {
|
|
137
132
|
test: /\.css$/,
|
|
138
133
|
use: [!isSSR && _miniCssExtractPlugin.default.loader, "css-loader", "postcss-loader"]
|
|
139
|
-
},
|
|
140
|
-
// TODO replace them with asset/module
|
|
141
|
-
{
|
|
134
|
+
}, {
|
|
142
135
|
test: /\.(png|jpg|gif|jpeg|ico?)$/,
|
|
143
136
|
use: ["url-loader?limit=10240", "img-loader"]
|
|
144
137
|
}, {
|
|
@@ -146,7 +139,7 @@ var _default = exports.default = {
|
|
|
146
139
|
issuer: /\.[jt]sx?$/,
|
|
147
140
|
use: ["@svgr/webpack", "url-loader?limit=10240", "img-loader"]
|
|
148
141
|
}, {
|
|
149
|
-
//
|
|
142
|
+
// This loader loads fonts in src/static/fonts using file-loader
|
|
150
143
|
test: /\.(ttf|eot|woff2|json?)$/,
|
|
151
144
|
use: [{
|
|
152
145
|
loader: "url-loader",
|
|
@@ -156,7 +149,7 @@ var _default = exports.default = {
|
|
|
156
149
|
}
|
|
157
150
|
}, "file-loader"]
|
|
158
151
|
}, {
|
|
159
|
-
//
|
|
152
|
+
// This loader loads html files
|
|
160
153
|
test: /\.html$/,
|
|
161
154
|
use: [{
|
|
162
155
|
loader: "html-loader",
|
|
@@ -11,19 +11,21 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
11
11
|
/* eslint-disable no-console */
|
|
12
12
|
|
|
13
13
|
const {
|
|
14
|
-
|
|
14
|
+
WEBPACK_DEV_SERVER_PORT,
|
|
15
|
+
WEBPACK_DEV_SERVER_HOSTNAME,
|
|
16
|
+
NODE_SERVER_PORT,
|
|
17
|
+
NODE_SERVER_HOSTNAME
|
|
15
18
|
} = process.env;
|
|
16
19
|
const catalystConfig = require(_path.default.resolve(__dirname, "..", "config.json"));
|
|
17
20
|
const plugins = require(_path.default.join(process.env.src_path, "webpackConfig.js"));
|
|
18
21
|
const webpackConfig = (0, _webpackMerge.default)(_baseBabel.default, {
|
|
19
22
|
devtool: "inline-source-map",
|
|
23
|
+
stats: "minimal",
|
|
20
24
|
plugins: [new _reactRefreshWebpackPlugin.default({
|
|
21
25
|
overlay: {
|
|
22
26
|
entry: false
|
|
23
27
|
}
|
|
24
|
-
}),
|
|
25
|
-
// TODO added in client and dev build
|
|
26
|
-
new _miniCssExtractPlugin.default({
|
|
28
|
+
}), new _miniCssExtractPlugin.default({
|
|
27
29
|
filename: catalystConfig.cssChunkFileName,
|
|
28
30
|
ignoreOrder: true
|
|
29
31
|
}), ...plugins.developmentPlugins].filter(Boolean),
|
|
@@ -33,7 +35,7 @@ const webpackConfig = (0, _webpackMerge.default)(_baseBabel.default, {
|
|
|
33
35
|
splitChunks: {
|
|
34
36
|
cacheGroups: {
|
|
35
37
|
commonVendor: {
|
|
36
|
-
test: /[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-
|
|
38
|
+
test: /[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,
|
|
37
39
|
name: "commonVendor",
|
|
38
40
|
minSize: 30000
|
|
39
41
|
},
|
|
@@ -57,12 +59,14 @@ const webpackConfig = (0, _webpackMerge.default)(_baseBabel.default, {
|
|
|
57
59
|
});
|
|
58
60
|
console.info("Firing up catalyst dev server...\n");
|
|
59
61
|
let devServer = new _webpackDevServer.default({
|
|
60
|
-
port:
|
|
62
|
+
port: WEBPACK_DEV_SERVER_PORT,
|
|
63
|
+
host: WEBPACK_DEV_SERVER_HOSTNAME,
|
|
61
64
|
static: {
|
|
62
65
|
publicPath: webpackConfig.output.publicPath
|
|
63
66
|
},
|
|
64
67
|
hot: true,
|
|
65
68
|
historyApiFallback: true,
|
|
69
|
+
open: [`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}`],
|
|
66
70
|
headers: {
|
|
67
71
|
"Access-Control-Allow-Origin": "*"
|
|
68
72
|
},
|
|
@@ -73,10 +77,9 @@ let devServer = new _webpackDevServer.default({
|
|
|
73
77
|
warnings: false,
|
|
74
78
|
runtimeErrors: false
|
|
75
79
|
},
|
|
76
|
-
progress: true,
|
|
77
80
|
reconnect: true
|
|
78
81
|
}
|
|
79
82
|
}, (0, _webpack.default)(webpackConfig));
|
|
80
83
|
devServer.startCallback(() => {
|
|
81
|
-
console.info(`Webpack dev server mounted at
|
|
84
|
+
console.info(`Webpack dev server mounted at http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}.`);
|
|
82
85
|
});
|
|
@@ -15,7 +15,6 @@ const {
|
|
|
15
15
|
} = require("webpack-merge");
|
|
16
16
|
const plugins = require(_path.default.join(process.env.src_path, "webpackConfig.js"));
|
|
17
17
|
const catalystConfig = require(_path.default.resolve(__dirname, "..", "config.json"));
|
|
18
|
-
const isSSR = !!process.env.SSR || false;
|
|
19
18
|
const clientConfig = mergeWithCustomize({
|
|
20
19
|
customizeArray: customizeArray({
|
|
21
20
|
entry: "prepend",
|
|
@@ -36,7 +35,7 @@ const clientConfig = mergeWithCustomize({
|
|
|
36
35
|
cacheGroups: {
|
|
37
36
|
commonVendor: {
|
|
38
37
|
chunks: "all",
|
|
39
|
-
test: /[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-
|
|
38
|
+
test: /[\\/]node_modules[\\/](react|react-dom|react-redux|react-router|react-router-dom|redux|redux-thunk|axios|react-loadable-visibility|react-helmet-async|react-fast-compare|react-async-script|babel|@loadable\/component|catalyst)[\\/]/,
|
|
40
39
|
name: "commonVendor",
|
|
41
40
|
minSize: 400000,
|
|
42
41
|
maxSize: 400000
|
|
@@ -36,7 +36,7 @@ const ssrConfig = mergeWithCustomize({
|
|
|
36
36
|
name: false
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
|
-
plugins: [...plugins.
|
|
39
|
+
plugins: [...plugins.ssrPlugins],
|
|
40
40
|
target: "node",
|
|
41
41
|
entry: {
|
|
42
42
|
handler: _path.default.resolve(__dirname, "..", "./server/renderer/handler.js")
|
|
@@ -52,8 +52,8 @@ const ssrConfig = mergeWithCustomize({
|
|
|
52
52
|
modulesDir: _path.default.join(rootWorkspacePath.path, "./node_modules")
|
|
53
53
|
})],
|
|
54
54
|
output: {
|
|
55
|
-
path: _path.default.join(process.env.src_path, process.env.
|
|
56
|
-
chunkFilename: catalystConfig.
|
|
55
|
+
path: _path.default.join(process.env.src_path, process.env.BUILD_OUTPUT_PATH, "/renderer"),
|
|
56
|
+
chunkFilename: catalystConfig.chunkFileNameProd,
|
|
57
57
|
filename: "handler.js",
|
|
58
58
|
libraryTarget: "commonjs"
|
|
59
59
|
}
|
package/webpack/scssParams.js
CHANGED
|
@@ -3,29 +3,33 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.imageUrl = exports.fontUrl = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* @description generate assets url according to enviorment
|
|
9
9
|
* @returns returns path required for loading assets according to enviorment
|
|
10
|
-
*/
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
*/
|
|
11
|
+
const imageUrl = () => {
|
|
12
|
+
const {
|
|
13
|
+
PUBLIC_STATIC_ASSET_URL,
|
|
14
|
+
PUBLIC_STATIC_ASSET_PATH
|
|
15
|
+
} = process.env;
|
|
16
|
+
let publicPath = `${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;
|
|
17
|
+
const imagePath = JSON.stringify(`${publicPath}images/`);
|
|
18
|
+
return imagePath;
|
|
17
19
|
};
|
|
18
20
|
|
|
19
21
|
/**
|
|
20
22
|
* @description generate assets font url according to enviorment
|
|
21
23
|
* @returns returns path required for loading fonts according to enviorment
|
|
22
|
-
*/
|
|
23
|
-
exports.
|
|
24
|
+
*/
|
|
25
|
+
exports.imageUrl = imageUrl;
|
|
24
26
|
const fontUrl = () => {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const {
|
|
28
|
+
PUBLIC_STATIC_ASSET_URL,
|
|
29
|
+
PUBLIC_STATIC_ASSET_PATH
|
|
30
|
+
} = process.env;
|
|
31
|
+
let publicPath = `${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;
|
|
32
|
+
const fontPath = JSON.stringify(`${publicPath}fonts/`);
|
|
33
|
+
return fontPath;
|
|
30
34
|
};
|
|
31
35
|
exports.fontUrl = fontUrl;
|
package/.prettierignore
DELETED
package/.prettierrc.json
DELETED
package/checkVersion.js
DELETED
package/config/config.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _default = exports.default = {
|
|
8
|
-
"S3_BUCKET": "stagassets.1mg.com",
|
|
9
|
-
"S3_FOLDER": "pwa-app",
|
|
10
|
-
"CDN_ASSET_PATH": "https://stagstatic.1mg.com",
|
|
11
|
-
"APPLICATION_PORT": "3005",
|
|
12
|
-
"APPLICATION_BASE_URL": "http://localhost:3005",
|
|
13
|
-
"SERVER_PATH": "http://localhost:3005",
|
|
14
|
-
"OUTPUT_PATH": "build",
|
|
15
|
-
"PUBLIC_OUTPUT_PATH": "build/public",
|
|
16
|
-
"PUBLIC_ASSET_PATH": "http://localhost:3006/assets/",
|
|
17
|
-
"LOCAL_ASSET_PATH": "/assets/",
|
|
18
|
-
"EXTERNAL_BASE_URL": "http://localhost:3005",
|
|
19
|
-
"DEV_SERVER_PORT": 3006,
|
|
20
|
-
"DEV_SERVER_HOSTNAME": "localhost",
|
|
21
|
-
"DEV_SERVER_HOST_URL": "http://localhost:3006",
|
|
22
|
-
"ENV_NAME": "local",
|
|
23
|
-
"BUILD_ENV": ""
|
|
24
|
-
};
|