bertramdev / asset-pipeline

The core implementation of the asset pipeline for the jvm
194 stars 92 forks source link

How can I use `node_modules` dir to use it as lib ? #193

Closed mariogarcia closed 6 years ago

mariogarcia commented 6 years ago

I'm trying to use asset-pipeline plugin with https://github.com/srs/gradle-node-plugin.

I would like to follow these steps:

//=require react

let sillyFunction = (x) => x;

I was able to make npmInstall to leave modules at src/assets/node_module but I don't know how to make assetCompile aware of the modules. Basically I would like to make src/assets/node_modules to behave as if it were src/assets/libs.

BTW: Awesome project!

davydotcom commented 6 years ago

asset-pipeline doesn't actually care what the folder name is inside of src/assets... you can make as many folders as you like and morpheus will detect and include them... I see you are using //=require react .. that would assume in src/assets/node_modules there is a react.js at the root of that folder. If there is not and its truly a module with a subfolder you need to require it specifically (the file)...

However as of asset-pipeline 3.0.x we now very deeply support ES6 modules and commonJs so one can simply do var React = require('react'); or something along those lines.