Merge pull request #260 from XhmikosR/master-resolve

Remove resolve dependency.
This commit is contained in:
Ben Zörb 2019-11-04 23:59:45 +01:00 committed by GitHub
commit c128a17e86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -46,7 +46,6 @@
"postcss-discard": "^0.3.2", "postcss-discard": "^0.3.2",
"prettier": "^1.18.2", "prettier": "^1.18.2",
"reaver": "^2.0.0", "reaver": "^2.0.0",
"resolve": "^1.12.0",
"slash": "^3.0.0", "slash": "^3.0.0",
"uglify-js": "^3.6.4" "uglify-js": "^3.6.4"
}, },

View File

@ -3,20 +3,19 @@
const fs = require('fs'); const fs = require('fs');
const path = require('path'); const path = require('path');
const {JSDOM} = require('jsdom'); const {JSDOM} = require('jsdom');
const resolve = require('resolve');
const detectIndent = require('detect-indent'); const detectIndent = require('detect-indent');
const flatten = require('lodash/flatten'); const flatten = require('lodash/flatten');
const UglifyJS = require('uglify-js'); const UglifyJS = require('uglify-js');
const loadCssMain = require.resolve('fg-loadcss');
/** /**
* Get loadcss + cssrelpreload script * Get loadcss + cssrelpreload script
* *
* @returns {string} Minified loadcss script * @returns {string} Minified loadcss script
*/ */
function getScript() { function getScript() {
const loadCssMain = resolve.sync('fg-loadcss'); const loadCSS = fs.readFileSync(path.join(path.dirname(loadCssMain), 'cssrelpreload.js'), 'utf8');
const loadCssBase = path.dirname(loadCssMain);
const loadCSS = fs.readFileSync(path.join(loadCssBase, 'cssrelpreload.js'), 'utf8');
return UglifyJS.minify(loadCSS).code.trim(); return UglifyJS.minify(loadCSS).code.trim();
} }