js-to-styles-var-loader icon indicating copy to clipboard operation
js-to-styles-var-loader copied to clipboard

Require is undefined importing in to a less file

Open owlyowl opened this issue 5 years ago • 5 comments

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.

owlyowl avatar Apr 23 '19 06:04 owlyowl

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

tompascall avatar Apr 23 '19 19:04 tompascall

Thanks for your reply yes it is.

On Wed, 24 Apr 2019 5:36 am Tamas G. Toth, [email protected] wrote:

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

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/tompascall/js-to-styles-var-loader/issues/8#issuecomment-485944360, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOT4CSF4VSYFIK7TCGFUTTPR5QL7ANCNFSM4HHU4JZA .

owlyowl avatar Apr 23 '19 20:04 owlyowl

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

wendyzhaogogo avatar Nov 27 '19 06:11 wendyzhaogogo

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

tompascall avatar Dec 01 '19 14:12 tompascall

@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.

wendyzhaogogo avatar Dec 02 '19 06:12 wendyzhaogogo