@rws-framework/client 2.14.1 → 2.15.2

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.
Files changed (46) hide show
  1. package/builder/vite/index.ts +0 -0
  2. package/builder/vite/loaders/html.ts +0 -0
  3. package/builder/vite/loaders/index.ts +0 -0
  4. package/builder/vite/loaders/loader.type.ts +0 -0
  5. package/builder/vite/loaders/scss.ts +0 -0
  6. package/builder/vite/loaders/ts.ts +0 -0
  7. package/builder/vite/rws.vite.config.ts +0 -0
  8. package/builder/vite/rws_scss_plugin.ts +0 -0
  9. package/builder/vite/scss/_compiler.ts +0 -0
  10. package/builder/vite/scss/_fonts.ts +0 -0
  11. package/builder/vite/scss/_fs.ts +0 -0
  12. package/builder/vite/scss/_import.ts +0 -0
  13. package/builder/webpack/after/copy.js +1 -0
  14. package/builder/webpack/after/sw.js +2 -2
  15. package/builder/webpack/loaders/rws_fast_scss_loader.js +4 -2
  16. package/builder/webpack/loaders/rws_fast_ts_loader.js +2 -3
  17. package/builder/webpack/rws.webpack.config.js +20 -30
  18. package/builder/webpack/rws_scss_plugin.js +25 -10
  19. package/builder/webpack/rws_webpack_plugin.js +2 -2
  20. package/builder/webpack/scss/_compiler.js +5 -6
  21. package/builder/webpack/scss/_fonts.js +2 -2
  22. package/builder/webpack/scss/_fs.js +3 -2
  23. package/builder/webpack/scss/_import.js +57 -21
  24. package/cfg/build_steps/vite/_build_config.ts +0 -0
  25. package/cfg/build_steps/vite/_env_defines.ts +0 -0
  26. package/cfg/build_steps/vite/_loaders.ts +0 -0
  27. package/cfg/build_steps/vite/index.ts +0 -0
  28. package/cfg/build_steps/vite/types.ts +0 -0
  29. package/cfg/build_steps/webpack/_actions.js +0 -0
  30. package/cfg/build_steps/webpack/_aliases.js +1 -2
  31. package/cfg/build_steps/webpack/_build_config.js +11 -12
  32. package/cfg/build_steps/webpack/_component_handling.js +1 -1
  33. package/cfg/build_steps/webpack/_dev_servers.js +0 -0
  34. package/cfg/build_steps/webpack/_env_defines.js +1 -1
  35. package/cfg/build_steps/webpack/_info.js +12 -5
  36. package/cfg/build_steps/webpack/_loaders.js +40 -19
  37. package/cfg/build_steps/webpack/_parser.js +118 -0
  38. package/cfg/build_steps/webpack/_plugins.js +6 -6
  39. package/cfg/build_steps/webpack/_production.js +8 -10
  40. package/cfg/build_steps/webpack/_rws_externals.js +2 -2
  41. package/cfg/build_steps/webpack/_webpack_config.js +9 -14
  42. package/cfg/tsconfigSetup.js +4 -7
  43. package/package.json +14 -14
  44. package/src/styles/README.md +158 -0
  45. package/src/styles/_grid_legacy.scss +50 -0
  46. package/tsconfig.json +19 -31
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -32,6 +32,7 @@ module.exports = async (copyList = {}, pluginCfg) => {
32
32
  // If sourcePath is a directory, collect all files recursively
33
33
  const allFiles = collectFiles(sourcePath);
34
34
  allFiles.forEach((file) => {
35
+
35
36
  const relativePath = path.relative(sourcePath, file);
36
37
  const targetFilePath = path.join(targetPath, relativePath);
37
38
  const targetFileDir = path.dirname(targetFilePath);
@@ -3,8 +3,8 @@ const chalk = require('chalk');
3
3
  const path = require('path');
4
4
  const tools = require('../../../_tools');
5
5
 
6
- module.exports = async (swPath) => {
7
- const swFilePath = path.resolve(process.cwd(), swPath);
6
+ module.exports = async (appRoot, swPath) => {
7
+ const swFilePath = path.resolve(appRoot, swPath);
8
8
 
9
9
  if(swPath.indexOf('.ts') === -1 || !fs.existsSync(swFilePath)){
10
10
  throw new Error('[RWS] Service worker TS file does not exist');
@@ -8,12 +8,14 @@ module.exports = async function(content) {
8
8
  const componentPath = path.resolve(componentDir, 'component.ts');
9
9
  const isDev = this._compiler.options.mode === 'development';
10
10
  const saveFile = content.indexOf('@save') > -1;
11
- const plugin = new RWSScssPlugin();
11
+ const plugin = new RWSScssPlugin({
12
+ rwsWorkspaceDir: this.query?.rwsWorkspaceDir
13
+ });
12
14
  let fromTs = false;
13
15
 
14
16
  if(saveFile){
15
17
  try {
16
- const codeData = await plugin.compileScssCode(content, path.dirname(filePath), null, filePath, !isDev);
18
+ const codeData = await plugin.compileScssCode(content, path.dirname(filePath));
17
19
 
18
20
  const code = codeData.code;
19
21
  const deps = codeData.dependencies;
@@ -12,8 +12,7 @@ module.exports = async function(content) {
12
12
  const filePath = this.resourcePath;
13
13
  const isDev = this._compiler.options.mode === 'development';
14
14
  let isIgnored = false;
15
- let isDebugged = false;
16
-
15
+ let isDebugged = false;
17
16
  // timingStart('decorator_extraction');
18
17
  const decoratorExtract = LoadersHelper.extractRWSViewArgs(processedContent);
19
18
  const decoratorData = decoratorExtract ? decoratorExtract.viewDecoratorData : null;
@@ -62,7 +61,7 @@ module.exports = async function(content) {
62
61
  try {
63
62
  if(tagName){
64
63
  const [template, htmlFastImports, templateExists] = await LoadersHelper.getTemplate(filePath, this.addDependency, templateName, isDev);
65
- const styles = await LoadersHelper.getStyles(filePath, this.addDependency, templateExists, stylesPath, isDev);
64
+ const styles = await LoadersHelper.getStyles(filePath, this.query?.rwsWorkspaceDir, this.query?.appRootDir,this.addDependency, templateExists, stylesPath, isDev);
66
65
 
67
66
  if(className){
68
67
  const replacedViewDecoratorContent = decoratorExtract.replacedDecorator;
@@ -18,11 +18,12 @@ const { executeRWSStartActions, timingActions, devActions } = require('../../cfg
18
18
  const { webpackDevServer } = require('../../cfg/build_steps/webpack/_dev_servers');
19
19
  const { RWS_WEBPACK_PLUGINS_BAG, addStartPlugins } = require('../../cfg/build_steps/webpack/_plugins');
20
20
 
21
- const _MAIN_PACKAGE = rwsPath.findRootWorkspacePath(process.cwd());
22
21
 
23
22
  // #SECTION INIT OPTIONS
24
23
 
25
- const RWSWebpackWrapper = async (rwsFrontendConfig) => {
24
+ const RWSWebpackWrapper = async (appRoot, rwsFrontendConfig, _packageDir) => {
25
+ const _MAIN_PACKAGE = rwsPath.findRootWorkspacePath(appRoot);
26
+
26
27
  const {
27
28
  executionDir,
28
29
  isWatcher,
@@ -42,11 +43,10 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
42
43
  devTools,
43
44
  devDebug,
44
45
  devRouteProxy,
45
- tsConfigPath,
46
+ tsConfig,
46
47
  rwsPlugins,
47
- _packageDir,
48
48
  BuildConfigurator
49
- } = await getBuildConfig(rwsFrontendConfig);
49
+ } = await getBuildConfig(rwsFrontendConfig, _packageDir);
50
50
 
51
51
  timeLog({ devDebug });
52
52
 
@@ -55,25 +55,20 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
55
55
  }
56
56
 
57
57
  rwsPath.removeDirectory(outputDir, true);
58
- buildInfo.start(executionDir, tsConfigPath, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, rwsFrontendConfig.rwsPlugins);
58
+ buildInfo.start(executionDir, tsConfig, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, rwsFrontendConfig.rwsPlugins);
59
59
 
60
60
  // #SECTION INIT PLUGINS && ENV VARS DEFINES
61
- addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, isHotReload, isReport, tsConfigPath);
61
+ addStartPlugins(rwsFrontendConfig, BuildConfigurator, devDebug, isHotReload, isReport);
62
62
 
63
63
  const WEBPACK_AFTER_ACTIONS = rwsFrontendConfig.actions || [];
64
64
  const WEBPACK_AFTER_ERROR_ACTIONS = rwsFrontendConfig.error_actions || [];
65
65
 
66
- const modules_setup = ['node_modules'];
66
+ const modules_setup = [path.resolve(tools.findRootWorkspacePath(executionDir), 'node_modules')];
67
67
 
68
68
  let optimConfig = null;
69
69
  let aliases = rwsFrontendConfig.aliases || {};
70
70
 
71
- console.log({
72
- __filename,
73
- _packageDir
74
- });
75
-
76
- aliases = { ...aliases, ...loadAliases(__dirname, path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir) }
71
+ aliases = { ...aliases, ...loadAliases(_packageDir, path.resolve(_MAIN_PACKAGE, 'node_modules'), executionDir) }
77
72
 
78
73
  // #SECTION PLUGIN STARTING HOOKS
79
74
 
@@ -85,22 +80,15 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
85
80
 
86
81
 
87
82
  // #SECTION RWS COMPONENT SCAN && PARTED PROCESSING
88
- const RWSComponents = scanComponents(await partedComponentsEvents(partedComponentsLocations, rwsPlugins, isParted), executionDir, __dirname);
83
+ const RWSComponents = scanComponents(await partedComponentsEvents(partedComponentsLocations, rwsPlugins, isParted), executionDir, _packageDir);
89
84
  console.log(`${chalk.cyanBright('RWS Scanned')} ${chalk.yellowBright(RWSComponents.length)} components`);
90
- const { automatedChunks, automatedEntries } = setComponentsChunks(rwsFrontendConfig.entry, RWSComponents, isParted);
85
+ const { automatedChunks, automatedEntries } = setComponentsChunks(rwsFrontendConfig.entrypoint, RWSComponents, isParted);
91
86
 
92
87
  // #SECTION RWS INFO FILE
93
88
  generateRWSInfoFile(outputDir, automatedEntries);
94
89
  console.log(chalk.greenBright(`RWSInfo file generated.`));
95
90
 
96
91
 
97
- // #SECTION TSCONFIG VALIDATION/SETUP
98
- const tsValidated = tools.setupTsConfig(tsConfigPath, executionDir, rwsFrontendConfig.aliases);
99
-
100
- if (!tsValidated) {
101
- throw new Error('RWS Webpack build failed.');
102
- }
103
-
104
92
  if (!isDev) {
105
93
  // #SECTION RWS PROD SETUP
106
94
 
@@ -121,14 +109,14 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
121
109
  actions: WEBPACK_AFTER_ACTIONS,
122
110
  error_actions: WEBPACK_AFTER_ERROR_ACTIONS,
123
111
  dev: isDev,
124
- devDebug
112
+ devDebug,
113
+ appRoot
125
114
  }));
126
115
  }
127
116
 
128
117
  // #SECTION RWS WEBPACK BUILD
129
- const cfgExport = createWebpackConfig(
118
+ const cfgExport = createWebpackConfig({
130
119
  executionDir,
131
- path.resolve(__dirname, '..', '..'),
132
120
  _packageDir,
133
121
  isDev,
134
122
  devTools,
@@ -140,11 +128,13 @@ const RWSWebpackWrapper = async (rwsFrontendConfig) => {
140
128
  automatedChunks,
141
129
  modules_setup,
142
130
  aliases,
143
- tsConfigPath,
144
- RWS_WEBPACK_PLUGINS_BAG.getPlugins(),
131
+ tsConfig,
132
+ WEBPACK_PLUGINS: RWS_WEBPACK_PLUGINS_BAG.getPlugins(),
145
133
  rwsExternals,
146
- devExternalsVars
147
- );
134
+ devExternalsVars,
135
+ appRootDir: appRoot,
136
+ entrypoint: rwsFrontendConfig.entrypoint
137
+ });
148
138
 
149
139
  if (optimConfig) {
150
140
  // setup production config if it got created above
@@ -13,17 +13,25 @@ let _scss_fs = null;
13
13
 
14
14
  class RWSScssPlugin {
15
15
  autoCompile = [];
16
-
17
- constructor(params) {
18
- this.node_modules_dir = (fileDir) => path.relative(fileDir, _tools.findRootWorkspacePath(process.cwd())) + '/node_modules/'
16
+ rwsWorkspaceDir = null;
17
+
18
+ constructor(params = {
19
+ appRootDir: null,
20
+ rwsWorkspaceDir: null,
21
+ autoCompile: []
22
+ }) {
23
+ this.node_modules_dir = (fileDir) => path.relative(fileDir, path.join(this.getRWSRootDir(), '/node_modules'))
19
24
  _scss_import = _scss_import_builder(this);
20
25
  _scss_fs = _scss_fs_builder(this);
21
26
  _scss_compiler = _scss_compiler_builder(this);
22
27
 
23
- if (!params) {
24
- params = {};
28
+ if(!params.rwsWorkspaceDir){
29
+ throw new Error('Pass "rwsWorkspaceDir" to the "@rws-framework/client/builder/webpack/loaders/rws_fast_ts_loader.js" loader.');
25
30
  }
26
31
 
32
+ this.rwsWorkspaceDir = params.rwsWorkspaceDir;
33
+ this.appRootDir = params.appRootDir;
34
+
27
35
  if (!!params.autoCompile && params.autoCompile.length > 0) {
28
36
  this.autoCompile = params.autoCompile;
29
37
  }
@@ -33,7 +41,6 @@ class RWSScssPlugin {
33
41
  this.compileFile(sassFile, true);
34
42
  }
35
43
  }
36
-
37
44
 
38
45
  apply(compiler) {
39
46
  const _self = this;
@@ -42,21 +49,29 @@ class RWSScssPlugin {
42
49
  }
43
50
 
44
51
  async compileFile(scssPath) {
45
- scssPath = _scss_import.processImportPath(scssPath, path.dirname(scssPath))
52
+ scssPath = _scss_import.processImportPath(scssPath, this.getRWSWorkspaceDir(), this.getRWSRootDir(),path.dirname(scssPath))
46
53
 
47
54
 
48
- let scssCode = _scss_fs.getCodeFromFile(scssPath);
55
+ let scssCode = _scss_fs.getCodeFromFile(scssPath, this.getRWSWorkspaceDir());
49
56
 
50
- return await _scss_compiler.compileScssCode(scssCode, path.dirname(scssPath), null, scssPath);
57
+ return await _scss_compiler.compileScssCode(scssCode, path.dirname(scssPath), this.getRWSWorkspaceDir(), this.getRWSRootDir());
51
58
  }
52
59
 
53
60
  async compileScssCode(scssCode, scssPath){
54
- return await _scss_compiler.compileScssCode(scssCode, scssPath, null, scssPath);
61
+ return await _scss_compiler.compileScssCode(scssCode, scssPath, this.getRWSWorkspaceDir(), this.getRWSRootDir());
55
62
  }
56
63
 
57
64
  writeCssFile(scssFilePath, cssContent){
58
65
  return _scss_fs.writeCssFile(scssFilePath, cssContent);
59
66
  }
67
+
68
+ getRWSWorkspaceDir() {
69
+ return this.rwsWorkspaceDir;
70
+ }
71
+
72
+ getRWSRootDir() {
73
+ return this.rwsWorkspaceDir;
74
+ }
60
75
  }
61
76
 
62
77
  module.exports = RWSScssPlugin;
@@ -3,7 +3,7 @@ const rwsAfterSW = require('./after/sw');
3
3
  const deepmerge = require('deepmerge');
4
4
 
5
5
 
6
- const _DEFAULT_CONFIG = { actions: [], executionDir: process.cwd(), packageDir: process.cwd(), dev: false, devDebug: null }
6
+ const _DEFAULT_CONFIG = { actions: [], executionDir: null, packageDir: null, dev: false, devDebug: null }
7
7
 
8
8
  const _DEFAULT_ACTION = {
9
9
  type: 'copy',
@@ -113,7 +113,7 @@ class RWSWebpackPlugin {
113
113
  case 'service_worker': {
114
114
 
115
115
  const serviceWorkerPath = typeof action === 'function' ? await action() : action;
116
- await rwsAfterSW(serviceWorkerPath);
116
+ await rwsAfterSW(this.config.appRoot, serviceWorkerPath);
117
117
  return;
118
118
  };
119
119
 
@@ -9,16 +9,15 @@ let _scss_fonts = null;
9
9
  const _scss_import_builder = require('./_import');
10
10
  let _scss_import = null;
11
11
 
12
- function compileScssCode(scssCode, fileRootDir, createFile = false, filePath = null, minify = false) {
12
+ function compileScssCode(scssCode, fileRootDir, rwsWorkspaceDir, appRoot) {
13
13
  _scss_fonts = _scss_fonts_builder(this);
14
- _scss_import = _scss_import_builder(this);
15
-
16
- const [scssImports] = _scss_import.extractScssImports(scssCode, fileRootDir);
14
+ _scss_import = _scss_import_builder(this);
15
+ const [scssImports] = _scss_import.extractScssImports(scssCode, rwsWorkspaceDir, appRoot, fileRootDir);
17
16
 
18
17
  const dependencies = scssImports.map((item) => item[2]);
19
18
 
20
19
  if (scssImports && scssImports.length) {
21
- scssCode = _scss_import.replaceImports(_scss_import.processImports(scssImports, fileRootDir), scssCode);
20
+ scssCode = _scss_import.replaceImports(_scss_import.processImports(scssImports, rwsWorkspaceDir, fileRootDir), scssCode);
22
21
  }
23
22
 
24
23
  const uses = _scss_import.extractScssUses(scssCode)[0];
@@ -39,7 +38,7 @@ function compileScssCode(scssCode, fileRootDir, createFile = false, filePath = n
39
38
  const result = sass.compileString(scssCode, { loadPaths: [fileRootDir]});
40
39
 
41
40
  let compiledCode = result.css.toString();
42
- compiledCode = _scss_fonts.replaceFontUrlWithBase64(compiledCode);
41
+ compiledCode = _scss_fonts.replaceFontUrlWithBase64(compiledCode, rwsWorkspaceDir, appRoot);
43
42
  compiledCode = replaceEmojisWithQuestionMark(compiledCode, fileRootDir);
44
43
  return { code: compiledCode, dependencies};
45
44
  } catch (err) {
@@ -44,7 +44,7 @@ function convertFontToBase64(fontPath) {
44
44
  return fs.readFileSync(fontPath, { encoding: 'base64' });
45
45
  }
46
46
 
47
- function replaceFontUrlWithBase64(cssContent) {
47
+ function replaceFontUrlWithBase64(cssContent, rwsWorkspaceDir, appRoot) {
48
48
  const fontFaceRegex = /@font-face\s*\{[^}]*\}/g;
49
49
  let fontFaces = [...cssContent.matchAll(fontFaceRegex)];
50
50
  _scss_import = _scss_import_builder(this);
@@ -58,7 +58,7 @@ function replaceFontUrlWithBase64(cssContent) {
58
58
 
59
59
  while ((match = urlRegex.exec(fontFaceContent)) !== null) {
60
60
  // Create a promise to convert each font to Base64 and replace in CSS
61
- const base64 = convertFontToBase64(_scss_import.processImportPath(match[2], null, true));
61
+ const base64 = convertFontToBase64(_scss_import.processImportPath(match[2], rwsWorkspaceDir, appRoot, null, true));
62
62
  const base64Font = `data:font/woff2;base64,${base64}`;
63
63
 
64
64
  modifiedFontFaceContent = modifiedFontFaceContent.replace(match[2], base64Font);
@@ -47,13 +47,14 @@ function readSCSSFilesFromDirectory(dirPath) {
47
47
  };
48
48
 
49
49
 
50
- function getCodeFromFile(filePath) {
50
+ function getCodeFromFile(filePath, rwsWorkspaceDir, appRootDir) {
51
51
  filePath = filePath.replace('//', '/');
52
52
  const _scss_import_builder = require('./_import');
53
53
  _scss_import = _scss_import_builder(this);
54
54
 
55
55
  if (!fs.existsSync(filePath)) {
56
- const processedImportPath = _scss_import.processImportPath(filePath, path.dirname(filePath));
56
+ const processedImportPath = _scss_import.processImportPath(filePath, rwsWorkspaceDir, appRootDir, path.dirname(filePath));
57
+
57
58
  if (!fs.existsSync(processedImportPath)) {
58
59
  throw new Error(`SCSS loader: File path "${filePath}" was not found.`);
59
60
  }
@@ -1,5 +1,5 @@
1
1
  const { rwsPath } = require('@rws-framework/console');
2
-
2
+ const chalk = require('chalk');
3
3
  const _scss_fs_builder = require('./_fs');
4
4
  let _scss_fs = null;
5
5
  const fs = require('fs');
@@ -7,26 +7,35 @@ const path = require('path');
7
7
  const CSS_IMPORT_REGEX = /^(?!.*\/\/)(?!.*\/\*).*@import\s+['"]((?![^'"]*:[^'"]*).+?)['"];?/gm;
8
8
  const SCSS_USE_REGEX = /^(?!.*\/\/)(?!.*\/\*).*@use\s+['"]?([^'"\s]+)['"]?;?/gm;
9
9
 
10
- const WORKSPACE = rwsPath.findRootWorkspacePath(process.cwd());
11
10
 
12
- function processImportPath(importPath, fileRootDir = null, noext = false) {
11
+ function processImportPath(importPath, rwsWorkspaceDir, appRootDir, fileRootDir = null, noext = false) {
12
+
13
13
  _scss_fs = _scss_fs_builder(this);
14
-
14
+ const workspaceDir = this.getRWSWorkspaceDir ? this.getRWSWorkspaceDir() : rwsWorkspaceDir;
15
+ const appRoot = this.getRWSWorkspaceDir ? this.getRWSRootDir() : appRootDir;
16
+
15
17
  if (importPath.split('')[0] === '~') {
16
- return fillSCSSExt(replaceWithNodeModules(importPath, null, true), noext);
18
+ return fillSCSSExt(replaceWithNodeModules(importPath, appRootDir, null, true), noext);
17
19
  }
18
20
 
19
21
  if (importPath.indexOf('@rws-mixins') === 0) {
20
- return path.resolve(rwsPath.findPackageDir(__dirname), 'src', 'styles', 'includes.scss');
22
+ return path.resolve(rwsPath.findPackageDir(workspaceDir), 'src', 'styles', 'includes.scss');
21
23
  }
22
24
 
23
25
  if (importPath.indexOf('@cwd') === 0) {
24
- return fillSCSSExt(process.cwd() + '/' + importPath.slice(4), noext);
26
+ return fillSCSSExt(path.join(this.appRootDir, importPath.slice(4)), noext);
25
27
  }
26
28
 
27
29
  if (importPath.split('')[0] === '/') {
30
+ const originalImport = fillSCSSExt(importPath, noext);
31
+
32
+ if(!fs.existsSync(originalImport)){
33
+ const absoluteImport = fillSCSSExt(path.join(workspaceDir, 'src', importPath), noext);
28
34
 
29
- return fillSCSSExt(importPath, noext);
35
+ return absoluteImport;
36
+ }
37
+
38
+ return originalImport;
30
39
  }
31
40
 
32
41
  if (fileRootDir) {
@@ -79,7 +88,30 @@ function fillSCSSExt(scssPath, noext = false) {
79
88
  return scssPath;
80
89
  }
81
90
 
82
- function extractScssImports(fileContent, importRootPath) {
91
+ function fillSCSSExt(scssPath, noext = false) {
92
+ const underscoredPath = underscorePath(scssPath, noext);
93
+ let ext = scssPath;
94
+
95
+ if (!fs.existsSync(scssPath) && fs.existsSync(underscoredPath)) {
96
+ ext = underscoredPath;
97
+ }
98
+
99
+ if (noext) {
100
+ ext = scssPath;
101
+ }
102
+
103
+ if ((!fs.existsSync(scssPath) || (fs.existsSync(scssPath) && fs.statSync(scssPath).isDirectory())) && fs.existsSync(`${scssPath}.scss`)) {
104
+ ext = `${scssPath}.scss`;
105
+ }
106
+
107
+ if (fs.existsSync(`_${scssPath}.scss`)) {
108
+ ext = `${scssPath}.scss`;
109
+ }
110
+
111
+ return ext;
112
+ }
113
+
114
+ function extractScssImports(fileContent, rwsWorkspaceDir, appRootDir, importRootPath) {
83
115
  _scss_fs = _scss_fs_builder(this);
84
116
  let match;
85
117
  const imports = [];
@@ -92,9 +124,9 @@ function extractScssImports(fileContent, importRootPath) {
92
124
  importRootPath = path.dirname(importRootPath);
93
125
  }
94
126
 
95
- const processedImportPath = processImportPath(importPath, importRootPath);
127
+ const processedImportPath = processImportPath(importPath, rwsWorkspaceDir, appRootDir, importRootPath);
96
128
 
97
- imports.push([processedImportPath, importLine, path.resolve(processedImportPath)]);
129
+ imports.push([processedImportPath, importLine, path.resolve(processedImportPath), rwsWorkspaceDir, appRootDir]);
98
130
  }
99
131
 
100
132
  return [imports, fileContent];
@@ -123,13 +155,14 @@ function detectImports(code) {
123
155
  return CSS_IMPORT_REGEX.test(code);
124
156
  }
125
157
 
126
- function replaceWithNodeModules(input, fileDir = null, absolute = false, token = '~') {
158
+ function replaceWithNodeModules(input, appRootDir, fileDir = null, absolute = false, token = '~') {
127
159
  _scss_fs = _scss_fs_builder(this);
128
- return input.replace(token, absolute ? `${path.resolve(WORKSPACE, 'node_modules')}/` : this.node_modules_dir(fileDir ? fileDir : process.cwd()));
160
+ return input.replace(token, absolute ? `${path.resolve(appRootDir, 'node_modules')}/` : this.node_modules_dir(fileDir ? fileDir : appRootDir));
129
161
  }
130
162
 
131
- function processImports(imports, fileRootDir, importStorage = {}, sub = false) {
163
+ function processImports(imports, fileRootDir, rwsWorkspaceDir, importStorage = {}, sub = false) {
132
164
  _scss_fs = _scss_fs_builder(this);
165
+
133
166
  const importResults = [];
134
167
 
135
168
  const getStorage = (sourceComponentPath, importedFileContent) => {
@@ -143,18 +176,21 @@ function processImports(imports, fileRootDir, importStorage = {}, sub = false) {
143
176
 
144
177
  return '';
145
178
  }
146
-
179
+
180
+
147
181
  imports.forEach(importData => {
148
182
  const originalImportPath = importData[0];
149
- let importPath = processImportPath(originalImportPath, fileRootDir);
150
- _scss_fs = _scss_fs_builder(this);
151
- let replacedScssContent = getStorage(importPath, _scss_fs.getCodeFromFile(importPath).replace(/\/\*[\s\S]*?\*\//g, ''));
183
+ const workspaceDir = this.getRWSWorkspaceDir ? this.getRWSWorkspaceDir() : importData[3];
184
+ const appRoot = this.getRWSWorkspaceDir ? this.getRWSRootDir() : importData[4];
152
185
 
153
- const recursiveImports = extractScssImports(replacedScssContent, importPath)[0];
186
+ let importPath = processImportPath(originalImportPath, workspaceDir, appRoot, fileRootDir);
154
187
 
155
- if (recursiveImports.length) {
188
+ let replacedScssContent = getStorage(importPath, _scss_fs.getCodeFromFile(importPath, workspaceDir).replace(/\/\*[\s\S]*?\*\//g, ''));
189
+
190
+ const recursiveImports = extractScssImports(replacedScssContent, workspaceDir, appRoot, importPath)[0];
156
191
 
157
- replacedScssContent = replaceImports(processImports(recursiveImports, path.dirname(importPath), importStorage, true), replacedScssContent);
192
+ if (recursiveImports.length) {
193
+ replacedScssContent = replaceImports(processImports(recursiveImports, path.dirname(importPath), workspaceDir, importStorage, true), replacedScssContent);
158
194
  }
159
195
 
160
196
  importResults.push({
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -1,8 +1,7 @@
1
1
  const path = require('path');
2
2
 
3
3
  function loadAliases(packageDir, nodeModulesPath, srcDir){
4
- return {
5
- 'src': srcDir + '/src',
4
+ return {
6
5
  '@rws-framework/foundation': path.resolve(packageDir, 'foundation', 'rws-foundation.js')
7
6
  }
8
7
  }
@@ -1,18 +1,18 @@
1
1
  const chalk = require('chalk');
2
+ const path = require('path');
3
+
2
4
  const { RWSConfigBuilder } = require('@rws-framework/console')
3
5
  const { rwsPath } = require('@rws-framework/console');
4
6
  const { _DEFAULT_CONFIG } = require('../../_default.cfg');
5
7
 
6
- async function getBuildConfig(rwsFrontBuildConfig){
7
- const BuildConfigurator = new RWSConfigBuilder(rwsPath.findPackageDir(process.cwd()) + '/.rws.json', {..._DEFAULT_CONFIG, ...rwsFrontBuildConfig});
8
- const _packageDir = rwsPath.findPackageDir(process.cwd());
9
-
10
- const executionDir = rwsPath.relativize(BuildConfigurator.get('executionDir') || rwsFrontBuildConfig.executionDir || process.cwd(), _packageDir);
8
+ async function getBuildConfig(rwsFrontBuildConfig, _packageDir){
9
+ const BuildConfigurator = new RWSConfigBuilder(path.join(rwsPath.findPackageDir(process.cwd()), '.rws.json'), {..._DEFAULT_CONFIG, ...rwsFrontBuildConfig});
10
+ const executionDir = rwsPath.relativize(BuildConfigurator.get('executionDir') || rwsFrontBuildConfig.executionDir || process.env.RWS_APP_ROOT || process.cwd(), _packageDir);
11
11
  const isWatcher = process.argv.includes('--watch') || false;
12
12
 
13
13
  const isDev = isWatcher ? true : (BuildConfigurator.get('dev', rwsFrontBuildConfig.dev) || false);
14
- const isHotReload = BuildConfigurator.get('hot', rwsFrontBuildConfig.hot);
15
- const isReport = BuildConfigurator.get('report', rwsFrontBuildConfig.report);
14
+ const isHotReload = BuildConfigurator.get('hotReload', rwsFrontBuildConfig.hotReload);
15
+ const isReport = BuildConfigurator.get('pkgReport', rwsFrontBuildConfig.pkgReport);
16
16
  const isParted = BuildConfigurator.get('parted', rwsFrontBuildConfig.parted || false);
17
17
 
18
18
  const partedPrefix = BuildConfigurator.get('partedPrefix', rwsFrontBuildConfig.partedPrefix);
@@ -20,7 +20,7 @@ async function getBuildConfig(rwsFrontBuildConfig){
20
20
 
21
21
  let partedComponentsLocations = BuildConfigurator.get('partedComponentsLocations', rwsFrontBuildConfig.partedComponentsLocations);
22
22
  const customServiceLocations = BuildConfigurator.get('customServiceLocations', rwsFrontBuildConfig.customServiceLocations); //@todo: check if needed
23
- const outputDir = rwsPath.relativize(BuildConfigurator.get('outputDir', rwsFrontBuildConfig.outputDir), _packageDir);
23
+ const outputDir = rwsPath.relativize(BuildConfigurator.get('outputDir', rwsFrontBuildConfig.outputDir), executionDir);
24
24
 
25
25
  const outputFileName = BuildConfigurator.get('outputFileName') || rwsFrontBuildConfig.outputFileName;
26
26
  const publicDir = BuildConfigurator.get('publicDir') || rwsFrontBuildConfig.publicDir;
@@ -37,7 +37,7 @@ async function getBuildConfig(rwsFrontBuildConfig){
37
37
 
38
38
  const devRouteProxy = BuildConfigurator.get('devRouteProxy') || rwsFrontBuildConfig.devRouteProxy;
39
39
 
40
- const tsConfigPath = rwsPath.relativize(BuildConfigurator.get('tsConfigPath') || rwsFrontBuildConfig.tsConfigPath, executionDir);
40
+ const tsConfig = BuildConfigurator.get('tsConfig') || rwsFrontBuildConfig.tsConfig;
41
41
 
42
42
  const rwsPlugins = {};
43
43
 
@@ -67,9 +67,8 @@ async function getBuildConfig(rwsFrontBuildConfig){
67
67
  devTools,
68
68
  devDebug,
69
69
  devRouteProxy,
70
- tsConfigPath,
71
- rwsPlugins,
72
- _packageDir,
70
+ tsConfig,
71
+ rwsPlugins,
73
72
  BuildConfigurator
74
73
  }
75
74
  }
@@ -41,7 +41,7 @@ function setComponentsChunks(clientEntry, RWSComponents = [], isParted = false)
41
41
  }
42
42
 
43
43
  function generateRWSInfoFile(outputDir, automatedEntries) {
44
- const rwsInfoJson = outputDir + '/rws_info.json'
44
+ const rwsInfoJson = path.join(outputDir, '/rws_info.json');
45
45
  fs.writeFile(rwsInfoJson, JSON.stringify({ components: Object.keys(automatedEntries) }, null, 2), () => {});
46
46
  }
47
47
 
File without changes
@@ -7,7 +7,7 @@ function processEnvDefines(BuildConfigurator, config, devDebug) {
7
7
  'process.env._RWS_BUILD_OVERRIDE': JSON.stringify(BuildConfigurator.exportBuildConfig())
8
8
  }
9
9
 
10
- const rwsDefines = BuildConfigurator.get('rwsDefines') || config.rwsDefines || null;
10
+ const rwsDefines = BuildConfigurator.get('env') || config.env || null;
11
11
 
12
12
  if (rwsDefines) {
13
13
  _rws_defines = { ..._rws_defines, ...rwsDefines }
@@ -1,11 +1,12 @@
1
1
  const chalk = require('chalk');
2
+ const util = require('util');
3
+
4
+
2
5
 
3
6
  module.exports = {
4
- start: (executionDir, tsConfigPath, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, rwsPlugins) => {
5
- console.log(chalk.green('Build started with'))
6
- console.log({
7
- executionDir,
8
- tsConfigPath,
7
+ start: (executionDir, tsConfig, outputDir, isDev, publicDir, isParted, partedPrefix, partedDirUrlPrefix, devTools, rwsPlugins) => {
8
+ console.log(chalk.green('RWS Frontend build started with:'), {
9
+ executionDir,
9
10
  outputDir,
10
11
  dev: isDev,
11
12
  publicDir,
@@ -15,5 +16,11 @@ module.exports = {
15
16
  devtool: devTools,
16
17
  plugins: rwsPlugins
17
18
  });
19
+
20
+ console.log(chalk.blue('\nTSCONFIG:'), util.inspect(tsConfig, {
21
+ depth: null,
22
+ colors: true,
23
+ maxArrayLength: null
24
+ }));
18
25
  }
19
26
  }