Last active
January 6, 2021 22:10
-
-
Save just-boris/b07d66e306c94cf42db41b010231fbbf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import path from 'path'; | |
function shouldApply(url) { | |
return path.extname(url) === '.css'; | |
} | |
export function getFormat(url, context, defaultGetFormat) { | |
if (shouldApply(url)) { | |
return { | |
format: 'module', | |
}; | |
} | |
return defaultGetFormat(url, context, defaultGetFormat); | |
} | |
export async function transformSource(source, context, defaultTransformSource) { | |
if (shouldApply(context.url)) { | |
return { source: '' }; | |
} | |
return defaultTransformSource(source, context, defaultTransformSource); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import './styles.css' | |
console.log('works!'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "css-node-loader", | |
"type": "module", | |
"version": "1.0.0", | |
"exports": { | |
".": "./css-loader.js" | |
}, | |
"scripts": { | |
"test": "node --loader ./css-loader.js demo.js" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.highlight { | |
color: blue; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment