less / less.js

Less. The dynamic stylesheet language.
http://lesscss.org
Apache License 2.0
17k stars 3.41k forks source link

Slow build of file with too many imports #3657

Closed kariae closed 2 years ago

kariae commented 2 years ago

I'm using Fomantic UI, which contains a .less file with many imports, and webpack/less-loader for the build. The build takes around 17 seconds, and when I do remove the imports the build goes to 2 seconds.

npx webpack-cli info` here in case they might help:

System:
    OS: macOS 11.6
    CPU: (8) arm64 Apple M1
    Memory: 70.17 MB / 8.00 GB
  Binaries:
    Node: 14.17.5 - ~/.nvm/versions/node/v14.17.5/bin/node
    Yarn: 1.22.11 - /opt/homebrew/bin/yarn
    npm: 6.14.14 - ~/.nvm/versions/node/v14.17.5/bin/npm
  Browsers:
    Chrome: 94.0.4606.81
    Safari: 15.0
  Packages:
    babel-loader: ^8.2.2 => 8.2.2
    css-loader: ^6.2.0 => 6.4.0
    css-minimizer-webpack-plugin: ^3.0.2 => 3.1.1
    less-loader: ^10.0.1 => 10.0.1
    postcss-loader: ^6.1.1 => 6.1.1
    sass-loader: ^12.1.0 => 12.1.0
    speed-measure-webpack-plugin: ^1.5.0 => 1.5.0
    style-loader: ^3.2.1 => 3.3.0
    ts-loader: ^9.2.5 => 9.2.6
    tsconfig-paths-webpack-plugin: ^3.5.1 => 3.5.1
    webpack: ^5.52.1 => 5.58.1
    webpack-cli: ^4.8.0 => 4.9.0
    webpack-dev-server: ^4.2.0 => 4.3.1
    webpack-merge: ^5.8.0 => 5.8.0
ryouaki commented 2 years ago

mark

ryouaki commented 2 years ago

This is my laptop, apple air m1.

  System:
    OS: macOS 11.5.1
    CPU: (8) arm64 Apple M1
    Memory: 93.55 MB / 8.00 GB
  Binaries:
    Node: 16.8.0 - ~/.nvm/versions/node/v16.8.0/bin/node
    npm: 6.14.15 - ~/.nvm/versions/node/v16.8.0/bin/npm
  Browsers:
    Chrome: 97.0.4692.71
    Safari: 14.1.2

I download the source code just less from git://github.com/fomantic/Fomantic-UI-LESS.git, and try build with lessc.

const now = Date.now()
require('less/bin/lessc')

process.on('exit', () => {
  console.log(Date.now() - now)
})

run with :

node ./index.js ./semantic.less ./theme.css

The build cast about 7s. So I do not think less is the mainly problem......But yes, it is a little slow......

You could build first ,and import the css file which built with lessc. I think this will be quickly....

kariae commented 2 years ago

thanks @ryouaki, since I'm watching files on change I'm not sure if I can build then import it would be the same.

I ended up cleaning the .less file, which made things much faster (around 3s) which is fine since I won't change it often.

Feel free to close this one, thank you.

iChenLei commented 2 years ago

Closed via https://github.com/less/less.js/issues/3657#issuecomment-1012838228