rollup-plugin-postcss icon indicating copy to clipboard operation
rollup-plugin-postcss copied to clipboard

Less Import Prefix

Open jcmcneal opened this issue 5 years ago • 3 comments

Can you add support to import module .less files with the prefix ~ like all the other bundles already do? Looks like this is already supported for sass, but why not less?

imports
For Sass/Scss Only.

Similar to how webpack's sass-loader works, you can prepend the path with ~ to tell this plugin to resolve in node_modules:

@import "~bootstrap/dist/css/bootstrap";

For example the error I'm seeing is similar to: [!] (postcss plugin) Error: '~my-package/lib/less/spinner.less' wasn't found.

Thanks.

jcmcneal avatar Dec 04 '18 18:12 jcmcneal

you can figure out like this:

import NpmImport from 'less-plugin-npm-import';
import postcss from 'rollup-plugin-postcss';

export default {
  ......
  plugins: [
    postcss({
      use: [['less', {
        plugins: [new NpmImport({prefix: '~'})],
      }]],
    }),
 ]
}

clock157 avatar Dec 16 '18 08:12 clock157

Sweet, thanks!

jcmcneal avatar Dec 21 '18 18:12 jcmcneal

you can figure out like this:

import NpmImport from 'less-plugin-npm-import';
import postcss from 'rollup-plugin-postcss';

export default {
  ......
  plugins: [
    postcss({
      use: [['less', {
        plugins: [new NpmImport({prefix: '~'})],
      }]],
    }),
 ]
}

working for me. Thank you

wbcs avatar Jan 05 '22 13:01 wbcs