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

Lib or component is not found if use nodejs path module on Windows #12

Open
patrickalima98 opened this issue Oct 27, 2019 · 2 comments
Open

Comments

@patrickalima98
Copy link

Hello @Gomah, after trying include a stencil lib using path.resolve(), the nuxt-stencil can't find the module.

The problem is because the Windows use \ and not /, so your plugin.ts, is generate this file:

image

With this, I get this response:

image

But, if I replace \ to /, works fine.

I have an idea how to fix it, if you agree, I can make a PR :)

Steps for to reproduce:

1- Add any stencil lib or component in the static folder.
2- Make the configuration using the path module.
3- run npm run dev
4- check the terminal and stencil.js in .nuxt/stencil.js.

My nuxt.config.js:

// const locales = require('./lang');
import path from 'path';
import locales from './lang/index';

export default {
  mode: 'spa',
  /*
  ** Headers of the page
  */
  head: {
    title: '',
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: process.env.npm_package_description || '' },
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' },
    ],
  },
  /*
  ** Customize the progress-bar color
  */
  loading: { color: '#fff' },
  /*
  ** Global CSS
  */
  css: [
  ],
  /*
  ** Plugins to load before mounting the App
  */
  plugins: [
  ],
  /*
  ** Nuxt.js dev-modules
  */
  buildModules: ['@nuxt/typescript-build'],
  /*
  ** Nuxt.js modules
  */
  modules: [
    ['nuxt-i18n', {
      locales,
      lazy: true,
      langDir: 'lang/',
      strategy: 'prefix',
      defaultLocale: 'pt-br',
    }],
    'nuxt-stencil',
  ],
  /*
  ** Build configuration
  */
  build: {
    /*
    ** You can extend webpack config here
    */
    extend(config, ctx) {
    },
    babel: {
      plugins: [
        ['@babel/plugin-proposal-decorators', { legacy: true }],
        ['@babel/plugin-proposal-class-properties', { loose: true }],
      ],
    },
  },
  stencil: {
    /**
     * Required options
     */

    // Your library name, or the path to its root folder.
    lib: 'nuiverse-ui',

    // By default, it takes the lib name. e.g: bulmil/dist/hydrate
    hydratePath: path.join(__dirname, './static/nuiverse-ui/dist/hydrate'),

    // By default, it takes the lib name. e.g: bulmil/dist/loader
    loaderPath: path.join(__dirname, './static/nuiverse-ui/dist/loader'),

    // The prefix to whitelist
    prefix: 'nv-',
  },
};

My environment:

OS: Windows 10 x64 Version 1903
Node: 10.16.3
NPM: 6.9.0
Nuxt: 2.0.0
nuxt-stencil: 0.1.1

@Gomah
Copy link
Owner

Gomah commented Nov 13, 2019

I can't reproduce it as I'm not on Windows, so feel free to make a PR :)

@patrickalima98
Copy link
Author

Hi @Gomah, how are you? I opened the PR to fix this issue, Can you see this please? :)

PR:
#66

Thank you

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