@researchgate/babel-plugin-transform-scss-import-to-string
Advanced tools
Comparing version 0.1.0 to 0.1.1
@@ -1,2 +0,2 @@ | ||
const { resolve, dirname } = require('path'); | ||
const { resolve, dirname, join } = require('path'); | ||
const { readFileSync } = require('fs'); | ||
@@ -20,10 +20,14 @@ const { renderSync } = require('node-sass'); | ||
// Get full path to file and transpile it | ||
const fullScssFilePath = resolve( | ||
dirname(filename), | ||
const scssFileDirectory = resolve(dirname(filename)); | ||
const fullScssFilePath = join( | ||
scssFileDirectory, | ||
path.node.source.value | ||
); | ||
const rawScssContent = readFileSync(fullScssFilePath).toString(); | ||
const projectRoot = process.cwd(); | ||
const nodeModulesPath = join(projectRoot, 'node_modules'); | ||
const sassResult = renderSync({ | ||
data: rawScssContent, | ||
sourceMap: false, | ||
includePaths: [nodeModulesPath, scssFileDirectory, projectRoot], | ||
}); | ||
@@ -30,0 +34,0 @@ const transpiledContent = sassResult.css.toString() || ''; |
{ | ||
"name": "@researchgate/babel-plugin-transform-scss-import-to-string", | ||
"version": "0.1.0", | ||
"description": | ||
"Babel plugin for transforming SCSS imports to static variable declarations with transpiled CSS string", | ||
"version": "0.1.1", | ||
"description": "Babel plugin for transforming SCSS imports to static variable declarations with transpiled CSS string", | ||
"main": "lib/index.js", | ||
"files": ["lib/", "readme.md"], | ||
"files": [ | ||
"lib/", | ||
"readme.md" | ||
], | ||
"scripts": { | ||
@@ -12,11 +14,15 @@ "test": "jest" | ||
"repository": "researchgate/babel-plugin-transform-scss-import-to-string", | ||
"keywords": ["babel", "scss", "css", "inline", "transform"], | ||
"keywords": [ | ||
"babel", | ||
"scss", | ||
"css", | ||
"inline", | ||
"transform" | ||
], | ||
"author": "Sergey Bekrin <sergey@bekrin.me>", | ||
"license": "MIT", | ||
"bugs": { | ||
"url": | ||
"https://github.com/researchgate/babel-plugin-transform-scss-import-to-string/issues" | ||
"url": "https://github.com/researchgate/babel-plugin-transform-scss-import-to-string/issues" | ||
}, | ||
"homepage": | ||
"https://github.com/researchgate/babel-plugin-transform-scss-import-to-string#readme", | ||
"homepage": "https://github.com/researchgate/babel-plugin-transform-scss-import-to-string#readme", | ||
"devDependencies": { | ||
@@ -23,0 +29,0 @@ "babel-core": "^6.26.0", |
@@ -15,3 +15,3 @@ # `babel-plugin-transform-scss-import-to-string` | ||
``` | ||
npm install --save-dev babel-plugin-styled-components | ||
npm install --save-dev @researchgate/babel-plugin-transform-scss-import-to-string | ||
``` | ||
@@ -18,0 +18,0 @@ |
6791
73