@vue/component-compiler-utils
Advanced tools
Comparing version 1.1.0 to 1.2.0
@@ -0,1 +1,16 @@ | ||
<a name="1.2.0"></a> | ||
# [1.2.0](https://github.com/vuejs/component-compiler-utils/compare/v1.1.0...v1.2.0) (2018-04-26) | ||
### Bug Fixes | ||
* compile only lib directory ([#6](https://github.com/vuejs/component-compiler-utils/issues/6)) ([4f787b3](https://github.com/vuejs/component-compiler-utils/commit/4f787b3)) | ||
### Features | ||
* accept postcss options and plugins ([#7](https://github.com/vuejs/component-compiler-utils/issues/7)) ([1456e3d](https://github.com/vuejs/component-compiler-utils/commit/1456e3d)) | ||
<a name="1.1.0"></a> | ||
@@ -2,0 +17,0 @@ # [1.1.0](https://github.com/vuejs/component-compiler-utils/compare/9204f16...v1.1.0) (2018-04-24) |
@@ -9,2 +9,6 @@ import { LazyResult } from 'postcss'; | ||
trim?: boolean; | ||
preprocessLang?: string; | ||
preprocessOptions?: any; | ||
postcssOptions?: any; | ||
postcssPlugins?: any[]; | ||
} | ||
@@ -11,0 +15,0 @@ export interface StyleCompileResults { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const postcss = require("postcss"); | ||
const postcss_1 = require("postcss"); | ||
const trim_1 = require("./stylePlugins/trim"); | ||
const scoped_1 = require("./stylePlugins/scoped"); | ||
const styleProcessors_1 = require("./styleProcessors"); | ||
function compileStyle(options) { | ||
const { source, filename, id, map, scoped = true, trim = true } = options; | ||
const plugins = []; | ||
const { filename, id, scoped = true, trim = true, preprocessLang, postcssOptions, postcssPlugins } = options; | ||
const preprocessor = preprocessLang && styleProcessors_1.processors[preprocessLang]; | ||
const preProcessedSource = preprocessor && preprocess(options, preprocessor); | ||
const map = preProcessedSource ? preProcessedSource.map : options.map; | ||
const source = preProcessedSource ? preProcessedSource.code : options.source; | ||
const plugins = (postcssPlugins || []).slice(); | ||
if (trim) { | ||
@@ -15,6 +20,3 @@ plugins.push(trim_1.default()); | ||
} | ||
const postCSSOptions = { | ||
to: filename, | ||
from: filename | ||
}; | ||
const postCSSOptions = Object.assign({}, postcssOptions, { to: filename, from: filename }); | ||
if (map) { | ||
@@ -29,4 +31,7 @@ postCSSOptions.map = { | ||
const errors = []; | ||
if (preProcessedSource && preProcessedSource.errors.length) { | ||
errors.push(...preProcessedSource.errors); | ||
} | ||
try { | ||
result = postcss(plugins).process(source, postCSSOptions); | ||
result = postcss_1.default(plugins).process(source, postCSSOptions); | ||
// force synchronous transform (we know we only have sync plugins) | ||
@@ -47,1 +52,6 @@ code = result.css; | ||
exports.compileStyle = compileStyle; | ||
function preprocess(options, preprocessor) { | ||
return preprocessor.render(options.source, options.map, Object.assign({ | ||
filename: options.filename | ||
}, options.preprocessOptions)); | ||
} |
@@ -1,3 +0,3 @@ | ||
import postcss = require('postcss'); | ||
import * as postcss from 'postcss'; | ||
declare const _default: postcss.Plugin<any>; | ||
export default _default; |
@@ -59,3 +59,3 @@ "use strict"; | ||
// individual animation-name declaration | ||
if (/-?animation-name$/.test(decl.prop)) { | ||
if (/^(-\w+-)?animation-name$/.test(decl.prop)) { | ||
decl.value = decl.value.split(',') | ||
@@ -66,3 +66,3 @@ .map(v => keyframes[v.trim()] || v.trim()) | ||
// shorthand | ||
if (/-?animation$/.test(decl.prop)) { | ||
if (/^(-\w+-)?animation$/.test(decl.prop)) { | ||
decl.value = decl.value.split(',') | ||
@@ -69,0 +69,0 @@ .map(v => { |
@@ -1,3 +0,3 @@ | ||
import postcss = require('postcss'); | ||
import * as postcss from 'postcss'; | ||
declare const _default: postcss.Plugin<{}>; | ||
export default _default; |
@@ -15,2 +15,4 @@ import postcss, { ProcessOptions, LazyResult } from 'postcss' | ||
preprocessOptions?: any | ||
postcssOptions?: any | ||
postcssPlugins?: any[] | ||
} | ||
@@ -33,3 +35,5 @@ | ||
trim = true, | ||
preprocessLang | ||
preprocessLang, | ||
postcssOptions, | ||
postcssPlugins | ||
} = options | ||
@@ -41,3 +45,3 @@ const preprocessor = preprocessLang && processors[preprocessLang] | ||
const plugins = [] | ||
const plugins = (postcssPlugins || []).slice() | ||
if (trim) { | ||
@@ -51,2 +55,3 @@ plugins.push(trimPlugin()) | ||
const postCSSOptions: ProcessOptions = { | ||
...postcssOptions, | ||
to: filename, | ||
@@ -53,0 +58,0 @@ from: filename |
{ | ||
"name": "@vue/component-compiler-utils", | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"description": "Lower level utilities for compiling Vue single file components", | ||
@@ -9,3 +9,3 @@ "main": "dist/index.js", | ||
"test": "jest", | ||
"build": "tsc", | ||
"build": "rm -rf dist && tsc", | ||
"prepublishOnly": "yarn build && conventional-changelog -p angular -r 2 -i CHANGELOG.md -s" | ||
@@ -12,0 +12,0 @@ }, |
@@ -1,2 +0,2 @@ | ||
# @vue/component-compiler-utils | ||
# @vue/component-compiler-utils [![Build Status](https://circleci.com/gh/vuejs/component-compiler-utils/tree/master.svg?style=shield)](https://circleci.com/gh/vuejs/component-compiler-utils/) | ||
@@ -3,0 +3,0 @@ > Lower level utilities for compiling Vue single file components |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
48246
37
1341