I am trying to change the theme of iView in my Vue project. I followed the steps found in this link:
https://www.iviewui.com/docs/guide/theme-en
I created a folder called my-theme in my main project folder. Inside that, I have a file called index.less, which contains the styles for my theme. I also installed less-loader using the following command
npm install less-loader --save-dev
Then, I imported my theme in my main.js file like so:
import iView from 'iview';
import '../my-theme/index.less';
Vue.use(iView);
However, when I try to load my project, I get the following error:
Failed to compile.
./my-theme/index.less (./node_modules/css-loader??ref--10-oneOf-3-1!./node_modules/postcss-loader/src??ref--10-oneOf-3-2!./node_modules/less-loader/dist/cjs.js??ref--10-oneOf-3-3!./my-theme/index.less)
Module build failed (from ./node_modules/less-loader/dist/cjs.js):
Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/myusername/myapp/node_modules/less-loader/dist/index.js:8:36)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/myusername/myapp/node_modules/less-loader/dist/cjs.js:3:18)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
How can I solve this issue? Thanks for any help.
Update
I also installed less using npm install less --save. Now I get this error:
Failed to compile.
./my-theme/index.less (./node_modules/css-loader??ref--10-oneOf-3-1!./node_modules/postcss-loader/src??ref--10-oneOf-3-2!./node_modules/less-loader/dist/cjs.js??ref--10-oneOf-3-3!./my-theme/index.less)
Module build failed (from ./node_modules/less-loader/dist/cjs.js):
// https://github.com/ant-design/ant-motion/issues/44
.bezierEasingMixin();
^
Inline JavaScript is not enabled. Is it set in your options?
in /Users/myusername/myapp/node_modules/iview/src/styles/color/bezierEasing.less (line 110, column 0)
You need to enable javascript loaderOptions in vue.config.js
If you don't have vue.config.js file in the root folder of your project, let's create this file and paste the below code:
Otherwise, you just put this code to vue.config.js file. Your file now looks likes this: