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

custom build - build multiple projects with only one node_modules #3418

Closed
QuinsZouls opened this issue May 18, 2019 · 3 comments
Closed

custom build - build multiple projects with only one node_modules #3418

QuinsZouls opened this issue May 18, 2019 · 3 comments

Comments

@QuinsZouls
Copy link

I have multiple proyects of polymer, but each one has its own modules to be compiled

2019-05-18_10-21-34
2019-05-18_10-22-09

but what I need is to share the same node_modules for all the projects I have, since they all use the same modules

Using custom build tools for build pwa

const fs = require('fs-extra');
const polymerBuild = require('polymer-build');
const path = require('path');
const build = require('./build/build').build; // custom polymer builder
const utils = require('./util');

/**
 * @param {String} name 
 */
async function buildProyect(name) {
  var setting = require(path.join(
    __dirname,
    '..',
    'proyects',
    name,
    'polymer.json'
  ));
  setting.root = path.join(__dirname, '..', 'proyects', name); //configure path root of the proyect

  const project = new polymerBuild.PolymerProject(setting);
  const buildSettings = utils.getBuildSettings(name);
  let arr = [];
  for (setting of buildSettings) {
    arr.push(build(setting, project, name));
  }
  await Promise.all(arr);
}

if there are no node_modules in the project root, it does not compile the pwa

My idea is to put the node_modules in the project folder, but when doing this the constructor always looks in the root of the project, now my question is: How do I take the node_modules of the project directory to build the pwa?

2019-05-18_13-31-48

for that I tried to put the absolute path where the modules were in the file polymer.json, but it did not work

2019-05-18_13-37-28

@jsilvermist
Copy link
Contributor

What about using symlinks?

@QuinsZouls
Copy link
Author

i am used build script but apparently the script does not take up symlinks

@QuinsZouls
Copy link
Author

This is my implementation but I'm not sure if it's adequate

const symlinkDir = require('symlink-dir');
const path = require('path');

const modules = path.join(__dirname, '..', 'proyects', 'node_modules');

/**
 *
 * @param {String} utl path of node_modules 
 */
function createNodeLink(utl) {
  return symlinkDir(modules, utl)
    .then(result => {
      console.log(result);
      return symlinkDir(modules, utl);
    })
    .then(result => {
      console.log(result);
    })
    .catch(err => console.error(err));
}
module.exports = {
  createNodeLink
}

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

2 participants