diff --git a/dist/main.js b/dist/main.js new file mode 100644 index 0000000000000000000000000000000000000000..cf5cc730eaf7a457cd0d202024c2ae7448056fe9 --- /dev/null +++ b/dist/main.js @@ -0,0 +1,32 @@ +/* + * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development"). + * This devtool is neither made for production nor for readable output files. + * It uses "eval()" calls to create a separate source file in the browser devtools. + * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/) + * or disable the default devtool with "devtool: false". + * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/). + */ +/******/ (() => { // webpackBootstrap +/******/ var __webpack_modules__ = ({ + +/***/ "./src/index.js": +/*!**********************!*\ + !*** ./src/index.js ***! + \**********************/ +/***/ (() => { + +eval("var a = 1\n\n//# sourceURL=webpack://scss-to-css/./src/index.js?"); + +/***/ }) + +/******/ }); +/************************************************************************/ +/******/ +/******/ // startup +/******/ // Load entry module and return exports +/******/ // This entry module can't be inlined because the eval devtool is used. +/******/ var __webpack_exports__ = {}; +/******/ __webpack_modules__["./src/index.js"](); +/******/ +/******/ })() +; \ No newline at end of file diff --git a/file.js b/file.js new file mode 100644 index 0000000000000000000000000000000000000000..b6aecbbfafa2c3e8916707c4dcdb3854bdbb8c22 --- /dev/null +++ b/file.js @@ -0,0 +1,71 @@ +/** + * 读取一个目录中所有子目录和文件 + */ + const fs = require('fs') + const path = require('path') + + class File { + constructor(filename, name, ext, isFile, size, creeateTime, updateTime) { + this.filename = filename + this.name = name // 文件名 + this.ext = ext // 后缀 + this.isFile = isFile // 是否文件 + this.size = size // 文件大小 + this.creeateTime = creeateTime // 创建时间 + this.updateTime = updateTime // 更新时间 + } + + static async getFile(filename) { + const stat = await fs.promises.stat(filename) + const { size, birthtime, mtime } = stat + let name = path.basename(filename), + ext = path.extname(filename), + isFile = stat.isFile(), + creeateTime = new Date(birthtime), + updateTime = new Date(mtime); + return new File(filename, name, ext, isFile, size, creeateTime, updateTime) + } + + // 获取目录的所有子文件对象,如果是文件返回空数组 + async getChildren() { + if (this.isFile) { return [] } + let dirArr = await fs.promises.readdir(this.filename); + dirArr = dirArr.map(fileName => { + const filename = path.resolve(this.filename, fileName) + return File.getFile(filename) + }) + return Promise.all(dirArr) + } + + // 获取文件内容, 如果是目录,返回null + async getContent(isBuffer = false) { + if (!this.isFile) { return null } + if (isBuffer) { + return await fs.promises.readFile(this.filename) + } + return await fs.promises.readFile(this.filename, 'utf-8') + } + } + + async function readDir(dirname) { + const file = await File.getFile(dirname) + return await file.getChildren() + } + + const dirname = path.resolve(__dirname, '../src') + console.log(readDir(dirname)) + + async function test() { + const dirname = path.resolve(__dirname, '../src') + const filename = path.resolve(__dirname, './index.js') + + const dir = await File.getFile(dirname) + console.log('dir', await dir.getChildren()) + + const file = await File.getFile(filename) + console.log('file', file) + + } + test() + + \ No newline at end of file diff --git a/readFile.js b/readFile.js new file mode 100644 index 0000000000000000000000000000000000000000..6f3937cfac195fbd14327fbbd9ccdb44177c20e0 --- /dev/null +++ b/readFile.js @@ -0,0 +1,50 @@ +/** + * 读取一个目录中所有子目录和文件 + */ + const fs = require('fs') + const path = require('path') + +var fileArr = [] + +var acceptFile = ['scss'] + +var getFile = async function(pathStr){ + let dirArr = await fs.promises.readdir(pathStr); + + console.log(dirArr); + + dirArr.forEach(e => { + //文件夹 + let str = pathStr+'/'+e + if(!isFile(str)){ + getFile(str) + }else{ + let fileType = str.split('.')[str.split('.').length-1] + if(acceptFile.indexOf(fileType)!==-1){ + fileArr.push({ + outputPath:pathStr+'/', + inputPath:str + }) + } + } + }); + } + + + var isFile = function(filename){ + var stat = fs.lstatSync(filename); + var isFile = stat.isFile() + return isFile +} + +module.exports = { + getFile, + fileArr, +} + + +getFile('./src') + +// setTimeout(()=>{ +// console.log(fileArr); +// },5000) \ No newline at end of file diff --git a/readFileCall.js b/readFileCall.js new file mode 100644 index 0000000000000000000000000000000000000000..ead20b5a0769033781b1cdcf922ac90907bff0c2 --- /dev/null +++ b/readFileCall.js @@ -0,0 +1,76 @@ +/** + * 读取一个目录中所有子目录和文件 + */ + const fs = require('fs') + const path = require('path') + +var fileArr = [] + +var acceptFile = ['scss'] + +var getFile = function(pathStr,cb){ + fs.readdir(pathStr,function(err,dirArr){ + console.log(dirArr); + + dirArr.forEach(e => { + //文件夹 + let str = pathStr+'/'+e + if(!isFile(str)){ + getChildernFile(str) + }else{ + let fileType = str.split('.')[str.split('.').length-1] + if(acceptFile.indexOf(fileType)!==-1){ + fileArr.push({ + outputPath:pathStr+'/', + inputPath:str + }) + } + } + }); + + cb?cb():'' + }); + } + + var getChildernFile = function(pathStr){ + fs.readdir(pathStr,function(err,dirArr){ + console.log(dirArr); + + dirArr.forEach(e => { + //文件夹 + let str = pathStr+'/'+e + if(!isFile(str)){ + getFile(str) + }else{ + let fileType = str.split('.')[str.split('.').length-1] + if(acceptFile.indexOf(fileType)!==-1){ + fileArr.push({ + outputPath:pathStr+'/', + inputPath:str + }) + } + } + }); + }); + } + + + var isFile = function(filename){ + var stat = fs.lstatSync(filename); + var isFile = stat.isFile() + return isFile +} + +module.exports = { + getFile, + fileArr, +} + + +getFile('./src',function(){ + console.log(fileArr); +}) + +// setTimeout(()=>{ +// console.log(fileArr); +// },5000) \ No newline at end of file diff --git a/src/a.css b/src/a.css deleted file mode 100644 index a886be7d7ef53ce072002adc793e0c273ec200f6..0000000000000000000000000000000000000000 --- a/src/a.css +++ /dev/null @@ -1,4 +0,0 @@ -.aa{ - height: 100px; - background-color: #fff; -} \ No newline at end of file diff --git a/src/aa/a.css b/src/aa/a.css new file mode 100644 index 0000000000000000000000000000000000000000..ce0d73b3bde1943b45f2e104d6209affe8cbd23a --- /dev/null +++ b/src/aa/a.css @@ -0,0 +1,3 @@ +.aaa { + width: 100px; } + diff --git a/src/aa/a.scss b/src/aa/a.scss new file mode 100644 index 0000000000000000000000000000000000000000..604d638ee937d3ee8d29e10aff0e5e24a608520d --- /dev/null +++ b/src/aa/a.scss @@ -0,0 +1,3 @@ +.aaa{ + width: 100px; +} \ No newline at end of file diff --git a/src/aa/bb/b.css b/src/aa/bb/b.css new file mode 100644 index 0000000000000000000000000000000000000000..e918fa0308c880fce6d06b342288fd88ea28bfa4 --- /dev/null +++ b/src/aa/bb/b.css @@ -0,0 +1,3 @@ +.bs { + color: #000; } + diff --git a/src/aa/bb/b.scss b/src/aa/bb/b.scss new file mode 100644 index 0000000000000000000000000000000000000000..28396a86ff19ad05bc950ab959eead71c928302f --- /dev/null +++ b/src/aa/bb/b.scss @@ -0,0 +1,3 @@ +.bs{ + color: #000; +} \ No newline at end of file diff --git a/src/b.scss b/src/b.scss deleted file mode 100644 index fec517af3067b8f4f61db23cc72f2f67b240c02f..0000000000000000000000000000000000000000 --- a/src/b.scss +++ /dev/null @@ -1,6 +0,0 @@ -.aa{ - width: 100px; - .bb{ - height: 100px; - } -} \ No newline at end of file diff --git a/src/c.scss b/src/c.scss deleted file mode 100644 index b48c0d74b2ea4744eac39af14a3d8577e2c19c4b..0000000000000000000000000000000000000000 --- a/src/c.scss +++ /dev/null @@ -1,6 +0,0 @@ -.cc{ - margin: 0; - .dd{ - padding: 0; - } -} \ No newline at end of file diff --git a/src/index.js b/src/index.js new file mode 100644 index 0000000000000000000000000000000000000000..eabcd42093c49619069d12043aa0951ce94ce5b3 --- /dev/null +++ b/src/index.js @@ -0,0 +1 @@ +var a = 1 \ No newline at end of file diff --git a/src/sdk.css b/src/sdk.css new file mode 100644 index 0000000000000000000000000000000000000000..b8c8e7e690db643ccf7749a797dd31400826aa72 --- /dev/null +++ b/src/sdk.css @@ -0,0 +1,18 @@ +.v-divider { + webkit-transform: scale(1, 0.5); + transform: scale(1, 0.5); } + .v-divider--vertical { + webkit-transform: scale(0.5, 1); + transform: scale(0.5, 1); } + +.theme--light.v-divider { + background-color: #ebedf0; + border-width: 0; + height: 1px; + max-height: 1px; } + .theme--light.v-divider--vertical { + background-color: #ebedf0; + border-width: 0; + width: 1px; + max-width: 1px; } + diff --git a/src/sdk.scss b/src/sdk.scss new file mode 100644 index 0000000000000000000000000000000000000000..cf13b65505b066367279305ea1f5ca2b8867df34 --- /dev/null +++ b/src/sdk.scss @@ -0,0 +1,33 @@ + +@mixin scale($x,$y){ + webkit-transform: scale($x,$y); + transform: scale($x,$y); +} + +@mixin scaleX($val){ + webkit-transform: scaleX($val); + transform: scaleX($val); +} + +.v-divider{ + @include scale(1,0.5) + &--vertical{ + @include scale(0.5,1) + } +} + +.theme--light{ + &.v-divider{ + background-color:#ebedf0; + border-width:0; + height: 1px; + max-height: 1px; + + &--vertical{ + background-color:#ebedf0; + border-width:0; + width: 1px; + max-width: 1px; + } + } +} \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 257ace78352272365103240f62073d508cbcae8e..04ec5f0430dcf636e472c639db6ec1e250208b9e 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,6 +2,9 @@ const path = require('path'); const MiniCssExtractPlugin = require('mini-css-extract-plugin'); const entry = require('webpack-glob-entry') const FixStyleOnlyEntriesPlugin = require("webpack-fix-style-only-entries"); +const {getFile,fileArr} = require('./readFile'); + +getFile('./src') const baseConfig = { module : { @@ -20,15 +23,28 @@ const baseConfig = { path: path.resolve(__dirname, './'), }, } -module.exports = [ - { - ...baseConfig, - entry: entry('./src/*.scss'), - plugins: [ - new FixStyleOnlyEntriesPlugin(), - new MiniCssExtractPlugin({ - filename: 'css/[name].css' //css打包输出出口及文件名称 + +var useArr = [] + + +//暂时没想到好的办法处理异步递归完成的时间问题,延时5s进行打包 +module.exports = new Promise((resolve,reject)=>{ + setTimeout(() => { + console.log(fileArr); + fileArr.forEach(e => { + useArr.push({ + ...baseConfig, + entry: entry(e.inputPath), + plugins: [ + new FixStyleOnlyEntriesPlugin(), + new MiniCssExtractPlugin({ + filename: e.outputPath+'/[name].css' //css打包输出出口及文件名称 + }) + ], }) - ], - } -]; \ No newline at end of file + }); + + resolve(useArr) + + }, 5000); +})