diff --git a/README.md b/README.md index 8b00910..3edecff 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,21 @@ $ yarn add babel-plugin-console-source -D ````javascript { "plugins": [ + + // consoleSource // No options required + + // You can pass in the following options ["console-source", { - "segments": 1 + "segments": 1, // NOT REQUIRED // 0 = full file path (Default) // 1 = file name ONLY // 2 = file name and last segment + "splitSegment": '/' // How to split the path - NOT REQUIRED + // Default is / for Linux and OSX + // Windows users can use "\\" here if needed + }] ] } diff --git a/index.js b/index.js index 2871ba5..66a6d8b 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,7 @@ module.exports = () => { if(typeof opts.resolveFile === 'function') { file = opts.resolveFile(file); } else if (!opts || opts.segments !== 0) { - file = state.file.opts.filename.split("/"); + file = state.file.opts.filename.split(((opts.splitSegment) ? opts.splitSegment : '/')); let segs = file.slice(Math.max(file.length - opts.segments)); file = segs.join('/'); } diff --git a/package.json b/package.json index 019c104..aade38b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "babel-plugin-console-source", - "version": "2.0.3", + "version": "2.0.4", "main": "index.js", "repository": "https://github.com/peteringram0/babel-console-source", "author": "Peter Ingram ", diff --git a/tests/webpack.config.js b/tests/webpack.config.js index 4d7e5a1..01c2f58 100644 --- a/tests/webpack.config.js +++ b/tests/webpack.config.js @@ -22,7 +22,8 @@ module.exports = { plugins: [ [consoleSource, { - "segments": 2 + "segments": 1, + "splitSegment": "/" }] ] @@ -30,4 +31,4 @@ module.exports = { }, ] } -}; \ No newline at end of file +};