Git Product home page Git Product logo

js-to-styles-var-loader's People

Contributors

constgen avatar dainyl avatar dhharker avatar tompascall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

js-to-styles-var-loader's Issues

load js from node_modules

Hi,

Thanks for building this awesome project!

I am trying to load vars from an npm package (in /node_modules). This doesn't seem to be possible though.

Here are some things I tried:

  • require('@nulogy/tokens');;
  • require('@nulogy/tokens/index.js');;
  • require('~@nulogy/tokens'); and require('~@nulogy/tokens/index.js'); โ€“ using the ~ prefix from the less-loader webpack resolver syntax.
  • require('../../../node_modules/@nulogy/tokens/');
  • require('../../../node_modules/@nulogy/tokens/index.js');

I leven tried to set my node_modules folders (I am using yarn workspaces so I have two) in less_loader:

 { 
  loader: 'less-loader', 
    options: {
      paths: [
        path.resolve('node_modules'),
        path.resolve('../node_modules')
       ]
    } 
},

In all cases I got an error:

ERROR in ../node_modules/css-loader!../node_modules/less-loader/dist/cjs.js!../node_modules/js-to-styles-var-loader!./src/cssPreprocessorResearch/less.less
Module build failed: 


require('@nulogy/tokens');
^
Function 'require' is undefined
      in /Users/user/src/nulogy/design-system/sandbox/src/cssPreprocessorResearch/less.less (line 13, column 0)
 @ ./src/cssPreprocessorResearch/less.less 2:14-181 21:1-42:3 22:19-186
 @ ./src/cssPreprocessorResearch/less.story.js
 @ ./src \.story.js$
 @ ./.storybook/config.js
 @ multi ./node_modules/@storybook/react/dist/server/config/polyfills.js ./node_modules/@storybook/react/dist/server/config/globals.js ../node_modules/webpack-hot-middleware/client.js?reload=true ./.storybook/config.js

You can see the code on this branch: https://github.com/nulogy/design-system/tree/loading-js-vars-into-less-from-node-modules

My webpack config is here: https://github.com/nulogy/design-system/blob/loading-js-vars-into-less-from-node-modules/sandbox/.storybook/webpack.config.js

The less file is here in this folder: https://github.com/nulogy/design-system/tree/loading-js-vars-into-less-from-node-modules/sandbox/src/cssPreprocessorResearch

specifically: https://github.com/nulogy/design-system/blob/loading-js-vars-into-less-from-node-modules/sandbox/src/cssPreprocessorResearch/less.less

Working with js loaders

Hey I'm trying to use your loader in a project that is using babel-loader on the js. However, it seems that the way javascript is required through this module doesn't respect such loaders.

I've investigated using webpackContext.exec as a replacement for require, but ran into this issue webpack/webpack#667. That issue thread seems to imply that the functionality can be achieved using a child compiler.

Require is undefined importing in to a less file

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.