@shijiu/jsview-vue 0.9.269 → 0.9.274
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
|
@@ -7,7 +7,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
7
7
|
|
|
8
8
|
const compilerSfc = require("./compiler-sfc.cjs");
|
|
9
9
|
|
|
10
|
-
var findCacheDir = _interopDefaultLegacy(require("find-cache-dir"));
|
|
11
10
|
var fs = _interopDefaultLegacy(require('fs'));
|
|
12
11
|
var hash = _interopDefaultLegacy(require('hash-sum'));
|
|
13
12
|
var path = _interopDefaultLegacy(require('path'));
|
|
@@ -19,6 +18,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
19
18
|
|
|
20
19
|
const adaptPath = (path.posix || path);
|
|
21
20
|
|
|
21
|
+
var nodeModulesDir = path.resolve(process.cwd(), 'node_modules')
|
|
22
22
|
var cachedCssStyles = {}
|
|
23
23
|
|
|
24
24
|
function ensureSfcDescriptor(descriptor) {
|
|
@@ -107,7 +107,7 @@ function compileCssToJs(sfc, options) {
|
|
|
107
107
|
// styleCodeContainer.add(styleCode);
|
|
108
108
|
|
|
109
109
|
checkSelectors(node, styleInfo.styleFilePath, styleInfo.styleSelectors); // 检测selector是否已经处理过
|
|
110
|
-
styleImportContainer += `\nimport "${styleInfo.styleJsFilePath}";`
|
|
110
|
+
styleImportContainer += `\nimport "${path.relative(nodeModulesDir, styleInfo.styleJsFilePath)}";`
|
|
111
111
|
} else if(node.name === "keyframes") {
|
|
112
112
|
const styleFilePath = node.source.input.file;
|
|
113
113
|
const styleSelectors = new Set([node.params]);
|
|
@@ -151,7 +151,7 @@ function checkSelectors(node, styleFilePath, styleSelectors) {
|
|
|
151
151
|
const cachedSelectors = cachedCssStyles[cachedFilePath];
|
|
152
152
|
for(let selector of cachedSelectors) {
|
|
153
153
|
if(styleSelectors.has(selector)) { // 发现重复的selector
|
|
154
|
-
let errMsg = "JsView
|
|
154
|
+
let errMsg = "JsView Warn: Multi defined CSS selector '" + selector + "' from " + node.source.input.file + ".\n";
|
|
155
155
|
errMsg += "It has been defined in " + cachedFilePath + ".\n";
|
|
156
156
|
check(false, node.source.input.css, errMsg);
|
|
157
157
|
}
|
|
@@ -219,9 +219,10 @@ function compileAndSaveImportedNode(styleFilePath, styleNodes) {
|
|
|
219
219
|
})
|
|
220
220
|
|
|
221
221
|
// 保存到js文件并import到script中
|
|
222
|
-
const cacheDir =
|
|
223
|
-
|
|
224
|
-
|
|
222
|
+
const cacheDir = path.resolve(nodeModulesDir, '@shijiu', '.cache')
|
|
223
|
+
if (!fs.existsSync(cacheDir)) {
|
|
224
|
+
fs.mkdirSync(cacheDir);
|
|
225
|
+
}
|
|
225
226
|
const styleJsFileName = adaptPath.basename(styleFilePath) + `.${hash(styleFilePath)}.js`;
|
|
226
227
|
const styleJsFilePath = adaptPath.join(cacheDir, styleJsFileName);
|
|
227
228
|
|