Skip to content
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

Require is undefined importing in to a less file #8

Open
owlyowl opened this issue Apr 23, 2019 · 5 comments
Open

Require is undefined importing in to a less file #8

owlyowl opened this issue Apr 23, 2019 · 5 comments

Comments

@owlyowl
Copy link

owlyowl commented Apr 23, 2019

const getThemeConfig = (extractLess, themeNameToPassInToLess) => { return { test: /\.(css|less)$/, use: extractLess.extract({ use: [ { loader: "css-loader", options: { importLoaders: 1 } }, 'postcss-loader', { loader: "less-loader", options: { plugins: [ lessPlugins ], globalVars: { themeName: themeNameToPassInToLess, customThemeColor: '#0000ff' } } }, { loader: "js-to-styles-var-loader" } ], fallback: "style-loader" }) }; };

I have this as my less config but then at the top of a random less file I've included:
require('../globals/colors.js');

Unfortunately I'm getting required is undefined.

@tompascall
Copy link
Owner

tompascall commented Apr 23, 2019

Is the path correct (../globals/colors.js)?

@owlyowl
Copy link
Author

owlyowl commented Apr 23, 2019 via email

@wendyzhaogogo
Copy link

when i @import from ‘.less’ in a less file, it not work

@tompascall
Copy link
Owner

@WilkinWendy could you insert the error message you get? Would be nice to have more info about environment where the error occurs.

@wendyzhaogogo
Copy link

@tompascall i mean less allows us to @import a .less file in a less file ,in webpack this is handled by less-loader,. My problem is if try to load js-variables in a less file which is imported by another less file, the error occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants