# precss-compiler **Repository Path**: tobyliu/precss-compiler ## Basic Information - **Project Name**: precss-compiler - **Description**: 预处理器编译器,目前只支持sass 开启此编译器服务,能够将使用sass编写的css语法编译成网页、小程序可使用的css 除此还能监听文件的变化,自动编译css预处理文件,无需手动再次编译 - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-11-05 - **Last Updated**: 2020-12-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # precss-compiler #### 介绍 css预处理编译器,例如将sass编写的样式编写成css - 目前支持sass、less #### 安装教程 1. npm install precss-compiler -D or yarn add precss-compiler -D #### 使用说明 1. 在项目根路径创建precss.service.js,引入包,创建服务,大致如下:(注:也可直接在依赖包项目中example文件下的precss-c.js直接复制到根目录下,执行node precss-c.js命令 运行此文件),核心函数createService(options: ServiceConfig | string) ``` // 直接使用,不传参,默认使用sass处理编译,编译项目下的.scss文件 const { createService } = require('precss-compiler') createService() // 传入less字符串参数,使用less处理编译,编译项目下的.less文件 createService('less') ``` ``` const { createService } = require('precss-compiler') //createService(options: ServiceConfig | string) createService({ compile: { ext: '.wxss' } }) ``` 其中options可选项如下(ServiceConfig): ``` { openWatch: true, // 开启监听 watch: { filepath: '', // 监听文件夹绝对路径,监听要编译的文件 recursive: true // 开启监听所以子孙目录 }, compile: { type: 'sass', ext: '.wxss', includes: ['.scss'], excludes: [{ type: 'prefix', value: 'node_modules' }], sourceMap: false } } ``` 2. 根据自己所需配置完成,打开控制台cmd,输入node precss-c.js命令即可 #### 仓库 - https://gitee.com/tobyliu/precss-compiler #### 参与贡献 #### 特技