diff --git a/README.md b/README.md index d3b80ba..5b706bc 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": "", @@ -69,6 +70,10 @@ For real-life example go to [examples](https://github.com/sheerun/babel-plugin-f ## Options +### rootPath + +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"`. 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)