Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
170
rated 0 times [  176] [ 6]  / answers: 1 / hits: 57999  / 7 Years ago, fri, october 13, 2017, 12:00:00

I would like to use inline js in my less files but I get the following message:




Inline JavaScript is not enabled. Is it set in your options?




How can I enable that?


More From » npm

 Answers
46

I had same problem, I use webpack with less loader, I needed to add javascript option in less loader config:



{
test: /.less$/,
use: [{
loader: style-loader
}, {
loader: css-loader
}, {
loader: less-loader,
options: {
javascriptEnabled: true
}
}]
}


I found in the sourcecode of less compiler: https://github.com/less/less.js/blob/3.x/bin/lessc



that they parse js less option in this way:



        case 'js':
options.javascriptEnabled = true;
break;
case 'no-js':
console.error('The --no-js argument is deprecated, as inline JavaScript ' +
'is disabled by default. Use --js to enable inline JavaScript (not recommended).');
break;


So you should probably use '--js' in a static compilation ( command line ) or 'javascriptEnabled: true' in a dynamic compilation ( like webpack loader ) to enable javascript.


[#56233] Tuesday, October 10, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hayleevalenciac

Total Points: 164
Total Questions: 89
Total Answers: 106

Location: Burkina Faso
Member since Thu, Dec 15, 2022
2 Years ago
hayleevalenciac questions
Thu, Jan 23, 20, 00:00, 4 Years ago
Tue, Jan 7, 20, 00:00, 5 Years ago
Thu, Oct 17, 19, 00:00, 5 Years ago
;