-
-
Notifications
You must be signed in to change notification settings - Fork 197
less loader paths option doesn't work #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I would like to chime in that having to pass these kinds of options as query variables creates some nasty syntax. It would be nice to be able to set things like this using loader options. For example, setting search paths for the Sass loader is easy: 'sassLoader': {
'includePaths': [
path.join( __dirname, 'src/ui/styles' )
]
} |
@chrismbeckett Using query variables to pass options is standard way. see webpack using loaders document. Webpack also supports configuration object. But it doesn't work no matter how I pass paths option. There is a pr ( #75) for solving this problem. but hasn't merged yet. |
So to clarify, there's currently no way to pass the Have tried various combinations: {
test: /\.less$/,
loader: "style!css!less?includePath=" + path.resolve(__dirname, "../core/app/styles")
}, {
test: /\.less$/,
loader: "style!css!less?{'includePath': [path.resolve(__dirname, "../core/app/styles")]}"
}, {
test: /\.less$/,
loader: "style!css!less?{'paths': [path.resolve(__dirname, "../core/app/styles")}"
}, |
I can't get it to work either. |
Same here |
I use resolve.alias webpack configuration(see http://webpack.github.io/docs/configuration.html#resolve-alias) to solve this problem. In webpack.config.js:
for example, PATH_MAP is
then I can use
to import swiper.less, and use
to require swiper with es2015 syntax. Thank you all. |
The problem that I have is with the @import statements within the .less files themselves - I'm trying to use the semantic-ui-less package, which contains import statements of the form @import "../../theme.config" (the idea is that you put a theme.config in your own project which overrides the default theme). I can't modify the import statements to include the '~', and I can't use resolve.alias because (AFAICT) the @import paths aren't processed through the webpack resolver (which makes sense actually, as these files are part of the less build). |
Same for me. Seams like
but loader throws an error… 😕
|
@viridia Can you use the semantic-ui-less package's source code? I think maybe you can copy the source code into you project, then modify the source code. But it's a ugly way. Or there is another way. Create a new project which contains your less code and dependency library, then write a shell script, use lessc to compile less, then just move the result file to your original project. |
@Jastrzebowski Maybe you can try to use resolve.alias, and I use it to solve my problem. |
I have encountered the same issue. This embraces portability, the tilde hack makes things really a burden. |
I don't like tilde hack too, |
Is it the same problem for the rootpath parameters as well? I tried both includePath and rootpath and build still fails as webpack tried to resolveimports and urls in our less file: { |
Hello! Is there any news on this issue? Is it still not possible to pass |
Less does not map the CLI options one-by-one to API options 😢. You need to take a look at their source code. Here they are translating options.paths = match[2]
.split(os.type().match(/Windows/) ? /:(?!\\)|;/ : ':')
.map(function(p) {
if (p) {
return path.resolve(process.cwd(), p);
} You should also apply their path transformation if you're on Windows. |
Hello ! @jhnns even with your explanation, I don't really know what I should do to to include the path I want (in the context of storybook). Is there any easy way to set included paths or to specify |
Hello @jhnns! Thank you for your reply. I'm not sure I understood your explanation though. Could you explain, how do one specify path to look for LESS files from less-loader standpoint? Thank you. |
Starting with less-loader 4, you can now choose between the webpack resolver and the Less resolver. If you specify the Take a look at the README for further information. Does this answer your questions? @Kendos-Kenlen @slavafomin |
@jhnns Good news ! However, I think I do something wrong : config.module.loaders.push({test: /\.less$/, loader: "style!css!less"});
config.lessLoader = {
paths: [
path.resolve(__dirname, 'styles')
],
sourceMap: true
}; The resolved path is good but I still have a not found error. My error message is :
I suppose I do something wrong and I'm sorry if it's a stupid mistake... :/ |
less-loader 4.x requires webpack 2. If you're using webpack 2, the options need to applied like this: // webpack.config.js
module.exports = {
...
module: {
rules: [{
test: /\.less$/,
use: [{
loader: "style-loader"
}, {
loader: "css-loader"
}, {
loader: "less-loader", options: {
paths: [
path.resolve(__dirname, "node_modules")
]
}
}]
}]
}
}; as described in the README. |
Okay, that's why. Storybook require webpack ^1.13, that why. Thanks and sorry! |
I think, the |
In my project, there is a '/lib/css' folder. When I write less code in 'src' folder, I prefer
to
so, In my webpack.conf.js
according to less option usage (see http://lesscss.org/usage/#command-line-usage-options) and README.md (https://github.com/webpack/less-loader#less-options), but it seems doesn't work.
Is anything wrong ? Please help me out.
The text was updated successfully, but these errors were encountered: