Open nianxiongdi opened 5 years ago
This is a CommonJS module so it has to be imported with require('../')
. It won't work trying to import it as an ES6 module. Webpack supports CommonJS, but for some reason your webpack config says it can't find it. TypeScript supports CommonJS as well but for some reason, I get the same error as trying to import it as an ES6 module.
https://webpack.js.org/concepts/modules/
However, when I use the import extractCSS = require('extract-css');
, I get a message saying the babel config doesn't support it. That makes more sense to me.
https://www.typescriptlang.org/docs/handbook/modules.html
My guess is it doesn't work because you are using TypeScript, but I think for it to work with TypeScript, you need to use the TS compiler, not babel. Unless, it's just missing some other config.
Steps to reproduce