mirror of
https://gitee.com/dcloud/uni-preset-vue
synced 2025-04-21 04:36:22 +08:00
add strip-json-comments
This commit is contained in:
parent
725c921815
commit
60776dcae6
@ -51,13 +51,6 @@ module.exports = (api, options, rootOptions) => {
|
|||||||
autoprefixer: {},
|
autoprefixer: {},
|
||||||
'@dcloudio/vue-cli-plugin-uni/packages/postcss': {}
|
'@dcloudio/vue-cli-plugin-uni/packages/postcss': {}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
vue: {
|
|
||||||
baseUrl: '/',
|
|
||||||
assetsDir: 'static',
|
|
||||||
css: {
|
|
||||||
extract: false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
70
node_modules/strip-json-comments/index.js
generated
vendored
Normal file
70
node_modules/strip-json-comments/index.js
generated
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
'use strict';
|
||||||
|
var singleComment = 1;
|
||||||
|
var multiComment = 2;
|
||||||
|
|
||||||
|
function stripWithoutWhitespace() {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function stripWithWhitespace(str, start, end) {
|
||||||
|
return str.slice(start, end).replace(/\S/g, ' ');
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = function (str, opts) {
|
||||||
|
opts = opts || {};
|
||||||
|
|
||||||
|
var currentChar;
|
||||||
|
var nextChar;
|
||||||
|
var insideString = false;
|
||||||
|
var insideComment = false;
|
||||||
|
var offset = 0;
|
||||||
|
var ret = '';
|
||||||
|
var strip = opts.whitespace === false ? stripWithoutWhitespace : stripWithWhitespace;
|
||||||
|
|
||||||
|
for (var i = 0; i < str.length; i++) {
|
||||||
|
currentChar = str[i];
|
||||||
|
nextChar = str[i + 1];
|
||||||
|
|
||||||
|
if (!insideComment && currentChar === '"') {
|
||||||
|
var escaped = str[i - 1] === '\\' && str[i - 2] !== '\\';
|
||||||
|
if (!escaped) {
|
||||||
|
insideString = !insideString;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (insideString) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!insideComment && currentChar + nextChar === '//') {
|
||||||
|
ret += str.slice(offset, i);
|
||||||
|
offset = i;
|
||||||
|
insideComment = singleComment;
|
||||||
|
i++;
|
||||||
|
} else if (insideComment === singleComment && currentChar + nextChar === '\r\n') {
|
||||||
|
i++;
|
||||||
|
insideComment = false;
|
||||||
|
ret += strip(str, offset, i);
|
||||||
|
offset = i;
|
||||||
|
continue;
|
||||||
|
} else if (insideComment === singleComment && currentChar === '\n') {
|
||||||
|
insideComment = false;
|
||||||
|
ret += strip(str, offset, i);
|
||||||
|
offset = i;
|
||||||
|
} else if (!insideComment && currentChar + nextChar === '/*') {
|
||||||
|
ret += str.slice(offset, i);
|
||||||
|
offset = i;
|
||||||
|
insideComment = multiComment;
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
} else if (insideComment === multiComment && currentChar + nextChar === '*/') {
|
||||||
|
i++;
|
||||||
|
insideComment = false;
|
||||||
|
ret += strip(str, offset, i + 1);
|
||||||
|
offset = i + 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret + (insideComment ? strip(str.substr(offset)) : str.substr(offset));
|
||||||
|
};
|
42
node_modules/strip-json-comments/package.json
generated
vendored
Normal file
42
node_modules/strip-json-comments/package.json
generated
vendored
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"name": "strip-json-comments",
|
||||||
|
"version": "2.0.1",
|
||||||
|
"description": "Strip comments from JSON. Lets you use comments in your JSON files!",
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "sindresorhus/strip-json-comments",
|
||||||
|
"author": {
|
||||||
|
"name": "Sindre Sorhus",
|
||||||
|
"email": "sindresorhus@gmail.com",
|
||||||
|
"url": "sindresorhus.com"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=0.10.0"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "xo && ava"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"index.js"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"json",
|
||||||
|
"strip",
|
||||||
|
"remove",
|
||||||
|
"delete",
|
||||||
|
"trim",
|
||||||
|
"comments",
|
||||||
|
"multiline",
|
||||||
|
"parse",
|
||||||
|
"config",
|
||||||
|
"configuration",
|
||||||
|
"conf",
|
||||||
|
"settings",
|
||||||
|
"util",
|
||||||
|
"env",
|
||||||
|
"environment"
|
||||||
|
],
|
||||||
|
"devDependencies": {
|
||||||
|
"ava": "*",
|
||||||
|
"xo": "*"
|
||||||
|
}
|
||||||
|
}
|
@ -14,6 +14,7 @@
|
|||||||
"isbinaryfile": "^3.0.3",
|
"isbinaryfile": "^3.0.3",
|
||||||
"ora": "^3.0.0",
|
"ora": "^3.0.0",
|
||||||
"rimraf": "^2.6.2",
|
"rimraf": "^2.6.2",
|
||||||
|
"strip-json-comments": "^2.0.1",
|
||||||
"user-home": "^2.0.0"
|
"user-home": "^2.0.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,6 +554,10 @@ strip-dirs@^2.0.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
is-natural-number "^4.0.1"
|
is-natural-number "^4.0.1"
|
||||||
|
|
||||||
|
strip-json-comments@^2.0.1:
|
||||||
|
version "2.0.1"
|
||||||
|
resolved "http://registry.npm.taobao.org/strip-json-comments/download/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"
|
||||||
|
|
||||||
strip-outer@^1.0.0:
|
strip-outer@^1.0.0:
|
||||||
version "1.0.1"
|
version "1.0.1"
|
||||||
resolved "http://registry.npm.taobao.org/strip-outer/download/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631"
|
resolved "http://registry.npm.taobao.org/strip-outer/download/strip-outer-1.0.1.tgz#b2fd2abf6604b9d1e6013057195df836b8a9d631"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user