From e08762dff9f2c5e6b5936f82232734a142fa0706 Mon Sep 17 00:00:00 2001 From: Josh Johnston Date: Mon, 3 Aug 2015 16:27:44 +1000 Subject: [PATCH 1/3] added failing test case and change to make it pass --- index.js | 6 +++++- tests/cases/import-node-module/expected.css | 3 +++ tests/cases/import-node-module/main.js | 1 + 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/cases/import-node-module/expected.css create mode 100644 tests/cases/import-node-module/main.js diff --git a/index.js b/index.js index cfbfdac..61c17fa 100644 --- a/index.js +++ b/index.js @@ -73,7 +73,7 @@ module.exports = function (browserify, options) { // bundles var sourceByFile = {}; - browserify.transform(function transform (filename) { + function transform (filename) { // only handle .css files if (!cssExt.test(filename)) { return through(); @@ -104,6 +104,10 @@ module.exports = function (browserify, options) { console.error(err); }); }); + } + + browserify.transform(transform, { + global: true }); // wrap the `bundle` function diff --git a/tests/cases/import-node-module/expected.css b/tests/cases/import-node-module/expected.css new file mode 100644 index 0000000..f0a88f9 --- /dev/null +++ b/tests/cases/import-node-module/expected.css @@ -0,0 +1,3 @@ +._styles__foo { + color: #F00; +} diff --git a/tests/cases/import-node-module/main.js b/tests/cases/import-node-module/main.js new file mode 100644 index 0000000..59f8d0d --- /dev/null +++ b/tests/cases/import-node-module/main.js @@ -0,0 +1 @@ +var styles = require('cool-styles/styles.css'); From d3f88d4b817e5f3d2216c89de2794a4c493f6b12 Mon Sep 17 00:00:00 2001 From: Josh Johnston Date: Mon, 3 Aug 2015 16:48:23 +1000 Subject: [PATCH 2/3] un-git-ignore node_modules in test cases (because we want to test importing css from there) --- tests/cases/.gitignore | 1 + .../import-node-module/node_modules/cool-styles/styles.css | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 tests/cases/.gitignore create mode 100644 tests/cases/import-node-module/node_modules/cool-styles/styles.css diff --git a/tests/cases/.gitignore b/tests/cases/.gitignore new file mode 100644 index 0000000..cf4bab9 --- /dev/null +++ b/tests/cases/.gitignore @@ -0,0 +1 @@ +!node_modules diff --git a/tests/cases/import-node-module/node_modules/cool-styles/styles.css b/tests/cases/import-node-module/node_modules/cool-styles/styles.css new file mode 100644 index 0000000..092b8ad --- /dev/null +++ b/tests/cases/import-node-module/node_modules/cool-styles/styles.css @@ -0,0 +1,3 @@ +.foo { + color: #F00; +} From f563a47fa99bf263ae6b6602fc84476fd34dcac3 Mon Sep 17 00:00:00 2001 From: Josh Johnston Date: Mon, 3 Aug 2015 16:50:37 +1000 Subject: [PATCH 3/3] moved .gitignore so it doesn't get picked up as a testcase --- tests/{cases => }/.gitignore | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/{cases => }/.gitignore (100%) diff --git a/tests/cases/.gitignore b/tests/.gitignore similarity index 100% rename from tests/cases/.gitignore rename to tests/.gitignore