-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix: types * build: esm cmj 模式打包 less2css * ci: node set 18 * build: lodashes to lodash in cjs * ci: lint trigger
- Loading branch information
Showing
9 changed files
with
127 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// https://github.com/umijs/father/blob/father-build%401.22.5/packages/father-build/src/getBabelConfig.ts#L25 | ||
|
||
const transformImportLess2Css = () => { | ||
return { | ||
name: 'transform-import-less-to-css', | ||
visitor: { | ||
ImportDeclaration(path) { | ||
const re = /\.less$/; | ||
if (re.test(path.node.source.value)) { | ||
path.node.source.value = path.node.source.value.replace(re, '.css'); | ||
} | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
module.exports = transformImportLess2Css; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// https://github.com/hexh250786313/blog/issues/30 | ||
const { addLoader } = require('father/dist/builder/bundless'); | ||
|
||
module.exports = async (api) => { | ||
const loaders = await api.applyPlugins({ | ||
key: 'addPostcssLoader', | ||
initialValue: [ | ||
{ | ||
key: 'less-to-css', | ||
test: /\.less$/, | ||
loader: require.resolve('./loader-less-to-css'), // less 文件转 css 文件 | ||
}, | ||
], | ||
}); | ||
|
||
loaders.forEach((loader) => addLoader(loader)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const path = require('path'); | ||
const less = require('less'); | ||
const postcss = require('postcss'); | ||
const syntax = require('postcss-less'); | ||
const autoprefixer = require('autoprefixer'); | ||
|
||
const loader = function (lessContent) { | ||
const cb = this.async(); | ||
this.setOutputOptions({ | ||
ext: '.css', | ||
}); | ||
postcss([autoprefixer({})]) | ||
.process(lessContent, { syntax }) | ||
.then((result) => { | ||
// less 转 css | ||
less.render(result.content, (err, css) => { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
cb(null, css.css); | ||
}); | ||
}) | ||
.catch((err) => { | ||
console.error(err); | ||
}); | ||
}; | ||
|
||
module.exports = loader; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters