babel-plugin-import-static-files
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -26,5 +26,5 @@ 'use strict'; | ||
function getFile(state, absPath, opts) { | ||
var root = state.file.opts.sourceRoot || process.cwd(); | ||
var root = process.env.APP_ROOT ? _path2.default.resolve(process.env.APP_ROOT) : state.file.opts.sourceRoot || process.cwd(); | ||
var file = absPath.replace(root, ''); | ||
console.log(process.env.APP_ROOT, process.cwd(), root, file, _path2.default.join(root, file), _path2.default.join(opts.baseDir, file)); | ||
if (opts.baseDir) { | ||
@@ -31,0 +31,0 @@ file = _path2.default.join(opts.baseDir, file); |
{ | ||
"name": "babel-plugin-import-static-files", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Transforms static files import and copy files to /static folder for next.js applications.", | ||
@@ -14,3 +14,4 @@ "main": "lib/index.js", | ||
"test:run": "nyc --reporter=text-summary mocha 'test/**/*.spec.js'", | ||
"test:watch": "npm run test -- -- --watch" | ||
"test:watch": "npm run test -- -- --watch", | ||
"build:watch": "npm run build -- --watch" | ||
}, | ||
@@ -17,0 +18,0 @@ "repository": { |
@@ -7,3 +7,2 @@ # babel-plugin-import-static-files | ||
[![npm][npm-badge]][npm-link] | ||
[![Build Status][circle-badge]][circle-link] | ||
@@ -14,5 +13,6 @@ ## Table of Contents | ||
- [Installation](#installation) | ||
- [Options](#options) | ||
- [Usage](#usage) | ||
- [via babelrc](#via-babelrc) | ||
- [via Node API](#via-node-api) | ||
- [via JavaScript](#via-javascript) | ||
@@ -29,3 +29,3 @@ ## About | ||
// icon.png and icon.svg will be copied to project's root under static folder | ||
// icon.png and icon.svg will be copied to project's root under baseDir (defaults to "/static") folder | ||
// and code will be transformed to: | ||
@@ -53,2 +53,29 @@ | ||
## Options | ||
Default options: | ||
```json | ||
{ | ||
"baseDir": "/static", | ||
"hash": false, | ||
"extensions": [ | ||
".gif", | ||
".jpeg", | ||
".jpg", | ||
".png", | ||
".svg" | ||
] | ||
} | ||
``` | ||
When hash is true (useful for assets caching): | ||
```js | ||
import image from './path/to/icon.png'; | ||
// icon.png will be copied to project's root under baseDir (defaults to "/static") folder | ||
// and code will be transformed to: | ||
const image = '/static/icon-[hash].png'; | ||
``` | ||
## Usage | ||
@@ -77,3 +104,3 @@ | ||
### via Node API | ||
### via JavaScript | ||
@@ -104,6 +131,3 @@ ```js | ||
[circle-badge]: https://img.shields.io/circleci/project/github/ahalimkara/babel-plugin-import-static-files/master.svg?style=flat-square | ||
[circle-link]: https://circleci.com/gh/ahalimkara/babel-plugin-import-static-files | ||
[npm-badge]: https://img.shields.io/npm/v/babel-plugin-import-static-files.svg?style=flat-square | ||
[npm-link]: https://www.npmjs.com/package/babel-plugin-import-static-files |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
128
9382
6
89
4