How to use vue-native-scripts - 6 common examples

To help you get started, we’ve selected a few vue-native-scripts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github syumai / vue-native-custom-transformer-plugin / compiler / parsers / parseTemplate.js View on Github external
const compiler = require('vue-native-template-compiler');
const constants = require('vue-native-scripts/src/util/constants');

let pug;

try {
  pug = require('pug');
} catch (e) {
  console.log('pug not loaded');
}

const defaultTemplate = {
  import: `import { Component as ${constants.COMPONENT} } from 'react'`,
  render: `const ${constants.TEMPLATE_RENDER} = () => null`,
};

function transpileTemplateContent(content, lang) {
  if (lang === 'pug') {
    if (pug) {
      return pug.render(content);
    } else {
      throw new Error(`failed to load pug! please add pug as a dependency.`);
    }
  }
  return content;
}

function parseTemplate(template) {
  if (!template) {
github syumai / vue-native-custom-transformer-plugin / compiler / parsers / parseTemplate.js View on Github external
const compiler = require('vue-native-template-compiler');
const constants = require('vue-native-scripts/src/util/constants');

let pug;

try {
  pug = require('pug');
} catch (e) {
  console.log('pug not loaded');
}

const defaultTemplate = {
  import: `import { Component as ${constants.COMPONENT} } from 'react'`,
  render: `const ${constants.TEMPLATE_RENDER} = () => null`,
};

function transpileTemplateContent(content, lang) {
  if (lang === 'pug') {
    if (pug) {
      return pug.render(content);
    } else {
      throw new Error(`failed to load pug! please add pug as a dependency.`);
    }
  }
  return content;
}

function parseTemplate(template) {
  if (!template) {
    return defaultTemplate;
github syumai / vue-native-custom-transformer-plugin / compiler / parsers / parseScript.js View on Github external
function parseScript(script) {
  if (!script) {
    return defaultScript;
  }

  const scriptContent = script.content.replace(/\/\/\n/g, '').trim();
  const s = `const ${constants.SCRIPT_OPTIONS} = `;
  return scriptContent
    .replace(/[\s;]*module.exports[\s]*=/, `\n${s}`)
    .replace(/[\s;]*export[\s]+default[\s]*\{/, `\n${s} {`);
}
github syumai / vue-native-custom-transformer-plugin / compiler / parsers / parseScript.js View on Github external
const defaultScript = `const ${constants.SCRIPT_OPTIONS} = {}`;
const constants = require('vue-native-scripts/src/util/constants');

function parseScript(script) {
  if (!script) {
    return defaultScript;
  }

  const scriptContent = script.content.replace(/\/\/\n/g, '').trim();
  const s = `const ${constants.SCRIPT_OPTIONS} = `;
  return scriptContent
    .replace(/[\s;]*module.exports[\s]*=/, `\n${s}`)
    .replace(/[\s;]*export[\s]+default[\s]*\{/, `\n${s} {`);
}

module.exports = parseScript;
github GeekyAnts / vue-native-cli / src / utils / vueTransformerPlugin.js View on Github external
module.exports.transform = function({ src, filename, options }) {
  if (vueExtensions.some(ext => filename.endsWith("." + ext))) {
    return vueNativeScripts.transform({ src, filename, options });
  }
  return upstreamTransformer.transform({ src, filename, options });
};
github syumai / vue-native-custom-transformer-plugin / compiler / parsers / parseStyles.js View on Github external
function parseStyles(styles) {
  const parsedStylesObj = styles.reduce((prev, curr) => {
    const { content, lang } = curr;
    const transpiledContent = transpileStylesContent(content, lang);
    const cssAST = cssParse(transpiledContent);
    return Object.assign({}, prev, parseCSS(cssAST));
  }, {});
  return `const ${constants.CSS} = ${JSON.stringify(parsedStylesObj)}`;
}

vue-native-scripts

Compile Vue Native components to React Native

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis

Similar packages