@rws-framework/client 2.9.6 → 2.9.7

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@rws-framework/client",
3
3
  "private": false,
4
- "version": "2.9.6",
4
+ "version": "2.9.7",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
7
7
  "docs": "typedoc --tsconfig ./tsconfig.json"
@@ -1,10 +1,35 @@
1
1
  const path = require('path');
2
2
  const fs = require('fs');
3
+ const RWSScssPlugin = require('../rws_scss_plugin');
3
4
 
4
5
  module.exports = function(content) {
5
6
  const filePath = this.resourcePath;
6
7
  const componentDir = path.resolve(path.dirname(filePath), '..');
7
8
  const componentPath = path.resolve(componentDir, 'component.ts');
9
+ const isDev = this._compiler.options.mode === 'development';
10
+ const saveFile = content.indexOf('@save') > -1;
11
+ const plugin = new RWSScssPlugin();
12
+ let fromTs = false;
13
+
14
+ if(saveFile){
15
+ try {
16
+ const codeData = plugin.compileScssCode(content, path.dirname(filePath), null, filePath, !isDev);
17
+
18
+ const code = codeData.code;
19
+ const deps = codeData.dependencies;
20
+
21
+ for (const dependency of deps){
22
+ this.addDependency(dependency);
23
+ }
24
+
25
+ if (saveFile && code) {
26
+ plugin.writeCssFile(filePath, code);
27
+ }
28
+ } catch(e){
29
+ console.error(e);
30
+ return '';
31
+ }
32
+ }
8
33
 
9
34
  if(fs.existsSync(componentPath)){
10
35
  fs.writeFileSync(componentPath, fs.readFileSync(componentPath, 'utf-8'))