parent
6e3b874108
commit
92340a43ee
2
build.js
2
build.js
|
@ -6,7 +6,7 @@ Es.buildSync({
|
|||
outdir: 'dist',
|
||||
platform: 'node',
|
||||
format: 'esm',
|
||||
// minify: true,
|
||||
minify: true,
|
||||
bundle: true,
|
||||
target: 'node12'
|
||||
})
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@bytedo/less",
|
||||
"version": "0.0.1",
|
||||
"version": "1.0.0",
|
||||
"type": "module",
|
||||
"description": "less精简版",
|
||||
"homepage": "http://lesscss.org",
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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}"`
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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.'
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: []
|
||||
}
|
|
@ -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.'
|
||||
)
|
||||
|
|
|
@ -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`)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Reference in New Issue