From 4455cf7610bbc0e49bf5b599307626473d8fceac Mon Sep 17 00:00:00 2001 From: Sam Gilman Date: Tue, 26 Oct 2021 17:11:09 +0800 Subject: [PATCH 1/2] Add root path to options --- README.md | 5 +++++ src/index.js | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3b80ba..81b309b 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,7 @@ This is equivalent to following default configuration: { "name": "[hash].[ext]", "extensions": ["png", "jpg", "jpeg", "gif", "svg"], + "rootPath": "/root/path/to/app", "publicPath": "/public", "outputPath": "/public", "context": "", @@ -71,6 +72,10 @@ For real-life example go to [examples](https://github.com/sheerun/babel-plugin-f ### outputPath +This is a relative or absolute path to use with `outputPath` to ensure files are copied to the correct location. + +### outputPath + Tells where to put static files. By default it's `"/public"`. This path is relative to the root of project. Setting value `null` prevents the plugin to copy the file. diff --git a/src/index.js b/src/index.js index f5a6e33..10a6135 100644 --- a/src/index.js +++ b/src/index.js @@ -22,7 +22,7 @@ const applyTransform = (p, t, state, value, calleeName) => { if (options.extensions && options.extensions.indexOf(ext.slice(1)) >= 0) { try { - const rootPath = state.file.opts.sourceRoot || process.cwd() + const rootPath = options.rootPath || state.file.opts.sourceRoot || process.cwd() const scriptDirectory = dirname(resolve(state.file.opts.filename)) const filePath = resolve(scriptDirectory, value) From ed7078da198096796e02cb0301110f6d38202f36 Mon Sep 17 00:00:00 2001 From: Sam Gilman Date: Tue, 26 Oct 2021 17:15:05 +0800 Subject: [PATCH 2/2] Fix name in readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 81b309b..5b706bc 100644 --- a/README.md +++ b/README.md @@ -70,7 +70,7 @@ For real-life example go to [examples](https://github.com/sheerun/babel-plugin-f ## Options -### outputPath +### rootPath This is a relative or absolute path to use with `outputPath` to ensure files are copied to the correct location.