DocSpring / craco-antd

A craco plugin to use Ant Design with create-react-app
MIT License
234 stars 49 forks source link

customizeTheme with files that use JS throws error SyntaxError: Cannot use import statement outside a module #52

Open HernanFaifman opened 3 years ago

HernanFaifman commented 3 years ago

I have a couple of files that set up the theme and style variables for my App. I have them each in their own file and I import one another using the import syntax. I keep getting this compilation error when using customizeTheme and starting the App:

eg: let´s assume it says  import fontSize from "./fontSize"
SyntaxError: Cannot use import statement outside a module

The config is as follows:

const CracoAntDesignPlugin = require("craco-antd");
const { customVariables } = require("./src/styles/styles");

module.exports = {
    plugins: [
        {
            plugin: CracoAntDesignPlugin,
            options: {
                customizeTheme: {
                customVariables,
                },
                javascriptEnabled: true,
            },
        },
    ],
};