diff --git a/build.js b/build.js index 87cb73b..a873e16 100644 --- a/build.js +++ b/build.js @@ -6,7 +6,7 @@ Es.buildSync({ outdir: 'dist', platform: 'node', format: 'esm', - // minify: true, + minify: true, bundle: true, target: 'node12' }) diff --git a/package.json b/package.json index 4df0bb8..dd5e419 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bytedo/less", - "version": "0.0.1", + "version": "1.0.0", "type": "module", "description": "less精简版", "homepage": "http://lesscss.org", diff --git a/src/less-node/index.js b/src/less-node/index.js index b01a3ea..02b1d22 100644 --- a/src/less-node/index.js +++ b/src/less-node/index.js @@ -10,12 +10,10 @@ import PluginLoader from './plugin-loader' import fs from 'fs' import options from '../less/default-options' -// allow people to create less with their own environment -less.createFromEnvironment = createFromEnvironment less.PluginLoader = PluginLoader -less.fs = fs -less.FileManager = FileManager -less.UrlFileManager = UrlFileManager +// less.fs = fs +// less.FileManager = FileManager +// less.UrlFileManager = UrlFileManager // Set up options less.options = options diff --git a/src/less-node/url-file-manager.js b/src/less-node/url-file-manager.js index d628ab4..4e4244e 100644 --- a/src/less-node/url-file-manager.js +++ b/src/less-node/url-file-manager.js @@ -7,7 +7,6 @@ const isUrlRe = /^(?:https?:)?\/\//i import url from 'url' let request import AbstractFileManager from '../less/environment/abstract-file-manager.js' -import logger from '../less/logger' const UrlFileManager = function () {} UrlFileManager.prototype = Object.assign(new AbstractFileManager(), { @@ -53,7 +52,7 @@ UrlFileManager.prototype = Object.assign(new AbstractFileManager(), { } body = body.toString('utf8') if (!body) { - logger.warn( + console.warn( `Warning: Empty body (HTTP ${resp.statusCode}) returned by "${urlStr}"` ) } diff --git a/src/less/environment/environment.js b/src/less/environment/environment.js index a59f67a..f8888f6 100644 --- a/src/less/environment/environment.js +++ b/src/less/environment/environment.js @@ -3,8 +3,6 @@ * environment, file managers, and plugin manager */ -import logger from '../logger' - class Environment { constructor(externalEnvironment, fileManagers) { this.fileManagers = fileManagers || [] @@ -32,12 +30,12 @@ class Environment { getFileManager(filename, currentDirectory, options, environment, isSync) { if (!filename) { - logger.warn( + console.warn( 'getFileManager called with no filename.. Please report this issue. continuing.' ) } if (currentDirectory === undefined) { - logger.warn( + console.warn( 'getFileManager called with null directory.. Please report this issue. continuing.' ) } diff --git a/src/less/functions/data-uri.js b/src/less/functions/data-uri.js index 5c18de0..0051eea 100644 --- a/src/less/functions/data-uri.js +++ b/src/less/functions/data-uri.js @@ -1,7 +1,6 @@ import Quoted from '../tree/quoted' import URL from '../tree/url' import * as utils from '../utils' -import logger from '../logger' export default environment => { const fallback = (functionThis, node) => @@ -71,7 +70,7 @@ export default environment => { environment ) if (!fileSync.contents) { - logger.warn( + console.warn( `Skipped data-uri embedding of ${filePath} because file not found` ) return fallback(this, filePathNode || mimetypeNode) diff --git a/src/less/import-manager.js b/src/less/import-manager.js index 482191b..342633a 100644 --- a/src/less/import-manager.js +++ b/src/less/import-manager.js @@ -2,7 +2,6 @@ import contexts from './contexts' import Parser from './parser/parser' import LessError from './less-error' import * as utils from './utils' -import logger from './logger' export default function (environment) { // FileInfo = { @@ -49,7 +48,7 @@ export default function (environment) { const importedEqualsRoot = fullPath === importManager.rootFilename if (importOptions.optional && e) { callback(null, { rules: [] }, false, null) - logger.info( + console.info( `The file ${fullPath} was skipped because it was not found and the import was marked optional.` ) } else { diff --git a/src/less/index.js b/src/less/index.js index 72475c7..3d2e1b6 100644 --- a/src/less/index.js +++ b/src/less/index.js @@ -11,7 +11,6 @@ import LessError from './less-error' import transformTree from './transform-tree' import * as utils from './utils' import PluginManager from './plugin-manager' -import logger from './logger' import SourceMapOutput from './source-map-output' import SourceMapBuilder from './source-map-builder' import ParseTree from './parse-tree' @@ -54,8 +53,7 @@ export default function (environment, fileManagers) { LessError, transformTree, utils, - PluginManager, - logger + PluginManager } // Create a public API diff --git a/src/less/logger.js b/src/less/logger.js deleted file mode 100644 index 3380877..0000000 --- a/src/less/logger.js +++ /dev/null @@ -1,34 +0,0 @@ -export default { - error: function (msg) { - this._fireEvent('error', msg) - }, - warn: function (msg) { - this._fireEvent('warn', msg) - }, - info: function (msg) { - this._fireEvent('info', msg) - }, - debug: function (msg) { - this._fireEvent('debug', msg) - }, - addListener: function (listener) { - this._listeners.push(listener) - }, - removeListener: function (listener) { - for (let i = 0; i < this._listeners.length; i++) { - if (this._listeners[i] === listener) { - this._listeners.splice(i, 1) - return - } - } - }, - _fireEvent: function (type, msg) { - for (let i = 0; i < this._listeners.length; i++) { - const logFunction = this._listeners[i][type] - if (logFunction) { - logFunction(msg) - } - } - }, - _listeners: [] -} diff --git a/src/less/parse-tree.js b/src/less/parse-tree.js index 5f61540..2ad1a68 100644 --- a/src/less/parse-tree.js +++ b/src/less/parse-tree.js @@ -1,6 +1,5 @@ import LessError from './less-error' import transformTree from './transform-tree' -import logger from './logger' export default function (SourceMapBuilder) { class ParseTree { @@ -22,7 +21,7 @@ export default function (SourceMapBuilder) { try { const compress = Boolean(options.compress) if (compress) { - logger.warn( + console.warn( 'The compress option has been deprecated. ' + 'We recommend you use a dedicated css minifier, for instance see less-plugin-clean-css.' ) diff --git a/src/less/visitors/extend-visitor.js b/src/less/visitors/extend-visitor.js index bb649c3..b38b1f2 100644 --- a/src/less/visitors/extend-visitor.js +++ b/src/less/visitors/extend-visitor.js @@ -4,7 +4,6 @@ */ import tree from '../tree' import Visitor from './visitor' -import logger from '../logger' import * as utils from '../utils' /* jshint loopfunc:true */ @@ -144,7 +143,7 @@ class ProcessExtendsVisitor { if (!indices[`${extend.index} ${selector}`]) { indices[`${extend.index} ${selector}`] = true - logger.warn(`extend '${selector}' has no matches`) + console.warn(`extend '${selector}' has no matches`) } }) }