Skip to content

Commit 56b0148

Browse files
committed
fix(babel): add support for commonjs requires.
Also includes codecov integration. BREAKING CHANGE: Existing imports will have to change from ``` const conditionalImporter = require('node-sass-conditional-importer').default; ``` to ``` const conditionalImporter = require('node-sass-conditional-importer'); ```
1 parent 49bf9f9 commit 56b0148

File tree

6 files changed

+125
-9
lines changed

6 files changed

+125
-9
lines changed

.babelrc

Lines changed: 0 additions & 7 deletions
This file was deleted.

.babelrc.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module.exports = {
2+
presets: [
3+
[
4+
'@babel/preset-env',
5+
],
6+
],
7+
plugins: ['add-module-exports'],
8+
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ their (environment) extension prefix, similar to React Native's
66

77
[![npm](https://img.shields.io/npm/v/node-sass-conditional-importer.svg)](https://www.npmjs.com/package/node-sass-conditional-importer)
88
[![build status](https://travis-ci.org/codebymikey/node-sass-conditional-importer.svg?branch=master)](https://travis-ci.org/codebymikey/node-sass-conditional-importer)
9+
[![Codecov Coverage](https://img.shields.io/codecov/c/github/codebymikey/node-sass-conditional-importer/coverage.svg?style=flat-square)](https://codecov.io/gh/codebymikey/node-sass-conditional-importer/)
910

1011
It reads in a list of `environments` extension prefixes, which it'll attempt to use over the default file.
1112

package-lock.json

Lines changed: 110 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-sass-conditional-importer",
3-
"version": "0.0.0-development",
3+
"version": "0.0.0-semantically-released",
44
"description": "A node-sass importer for dynamically/conditionally resolving files based on their file extension prefix.",
55
"repository": {
66
"type": "git",
@@ -51,6 +51,8 @@
5151
"@semantic-release/changelog": "^5.0.1",
5252
"@semantic-release/git": "^9.0.0",
5353
"babel-eslint": "^10.1.0",
54+
"babel-plugin-add-module-exports": "^1.0.4",
55+
"codecov": "^3.8.1",
5456
"commitizen": "^4.2.2",
5557
"cz-conventional-changelog": "^3.3.0",
5658
"eslint": "^7.11.0",

test/index.test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import sass from 'node-sass';
44
import path from 'path';
55

66
import conditionalImporter from '../src';
7+
// Test both commonjs and ES6 import compatibility.
8+
const conditionalImporterCommonJS = require('../src');
79

810
describe('conditionalImporter', () => {
911
test('resolves the development _style.scss partial', function () {
@@ -127,7 +129,7 @@ describe('conditionalImporter', () => {
127129
file: './test/fixtures/partials/main.scss',
128130
outputStyle: 'compressed',
129131
importer: [
130-
conditionalImporter({
132+
conditionalImporterCommonJS({
131133
// Pass in a string.
132134
environments: 'production',
133135
}),

0 commit comments

Comments
 (0)