babel-plugin-cssta-stylename
Advanced tools
Comparing version 0.1.7 to 0.1.8
13
index.js
const utils = require('./utils') | ||
const DEFAULT_CLASS_ATTRIBUTE = 'styleName' | ||
const DEFAULT_ADD_CSS_HASH = true | ||
const DEFAULT_ADD_CSS_HASH = false | ||
const DEFAULT_EXTENSIONS = ['css', 'styl'] | ||
const ADD_CSS_HASH_DELAY = 300 | ||
@@ -14,2 +15,8 @@ const CSSTA_TEMPLATE = 'styled' | ||
function hasTargetExtension (filename = '', extensions = DEFAULT_EXTENSIONS) { | ||
const match = filename.match(/\.([^/]+)$/) | ||
const extension = match && match[1] | ||
return extension && extensions.includes(extension) | ||
} | ||
module.exports = ({ types: t }) => { | ||
@@ -128,3 +135,3 @@ let lastImport | ||
: DEFAULT_ADD_CSS_HASH | ||
if (addCssHash && /\.css$/.test(state.file.opts.filename)) { | ||
if (addCssHash && hasTargetExtension(state.file.opts.filename, state.opts.extensions)) { | ||
const filename = state.file.opts.filename | ||
@@ -155,3 +162,3 @@ // Delay execution to account for Save All delay in IDEs | ||
lastImport = p | ||
if (/\.css$/.test(p.node.source.value)) stylesImport = p | ||
if (hasTargetExtension(p.node.source.value, state.opts.extensions)) stylesImport = p | ||
} | ||
@@ -158,0 +165,0 @@ }) |
{ | ||
"name": "babel-plugin-cssta-stylename", | ||
"version": "0.1.7", | ||
"version": "0.1.8", | ||
"description": "Transform css imports into cssta template components", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
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
15131
297