SolidZORO / next-plugin-antd-less

🎩 Use Antd (Less) with Next.js v12, Zero Dependency on other Next-Plugins.
MIT License
345 stars 48 forks source link

Inline JavaScript is not enabled #4

Closed llamadeus closed 3 years ago

llamadeus commented 3 years ago

I'm getting the following error when using your package.


// https://github.com/ant-design/ant-motion/issues/44
.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?
      in node_modules/antd/lib/style/color/bezierEasing.less (line 110, column 0)

I have found out that javascriptEnabled is being set to true in the following snippet but the option is erroneously nested within the lessOptions object.

const lessLoaderIndex = lessModule.use.findIndex((item) => `${item.loader}`.includes('sass-loader'));
lessModule.use.splice(lessLoaderIndex, 1, {
  loader: 'less-loader',
  options: {
    lessOptions: {
      javascriptEnabled: true,
      modifyVars,
    },
  },
});

Instead the options should be set to true like this:

const lessLoaderIndex = lessModule.use.findIndex((item) => `${item.loader}`.includes('sass-loader'));
lessModule.use.splice(lessLoaderIndex, 1, {
  loader: 'less-loader',
  options: {
    javascriptEnabled: true,
    modifyVars,
  },
});
SolidZORO commented 3 years ago

https://github.com/SolidZORO/next-plugin-antd-less/blob/757f8df159242a5b772eba0ada225a0dd2260899/index.js#L68

llamadeus commented 3 years ago

https://github.com/SolidZORO/next-plugin-antd-less/blob/757f8df159242a5b772eba0ada225a0dd2260899/index.js#L68

I can see that javascriptEnabled is being set to true but it still does not work because the option should not be set to true within the lessOptions object but directly within the options object.

SolidZORO commented 3 years ago

this is less-loader BREAKING CHANGES.

https://github.com/webpack-contrib/less-loader/blob/master/CHANGELOG.md#600-2020-04-24

https://github.com/webpack-contrib/less-loader#lessoptions

if your still not work, pls update less-loader version to v6.0.0+.

llamadeus commented 3 years ago

Thanks! I found the root of the problem. Having your plugin installed along with @zeit/next-less caused two versions of less-loader being installed: 4.x and 6.x. Uninstalling @zeit/next-less solved the issue for me.

Also, thanks for this plugin! I really appreciate it.

tech-chieftain commented 2 years ago

Thanks! I found the root of the problem. Having your plugin installed along with @zeit/next-less caused two versions of less-loader being installed: 4.x and 6.x. Uninstalling @zeit/next-less solved the issue for me.

Also, thanks for this plugin! I really appreciate it.

@llamadeus removing @zeit/next-less solved this issue for me. Thanks!