Giter Site home page Giter Site logo

genuifx / wxa-cli Goto Github PK

View Code? Open in Web Editor NEW
3.0 2.0 0.0 617 KB

A CLI tool for development wechat miniprogram with wxa

Home Page: https://genuifx.github.io/wxa-doc

License: MIT License

JavaScript 99.14% Shell 0.86%
wxa-cli wxa wechat miniprogram

wxa-cli's Introduction

wxa-cli

Build Status NPM version

๐ŸŽ‰๐Ÿ˜ƒcli for wechat miniprogram developing.

Detail documents: @wxa/doc๐Ÿ’ฏ

ๆ›ดๅฎŒๅ–„็š„ๆ–‡ๆกฃ๏ผš@wxa/doc๐Ÿ’ฏ

mind-node

Feature

  • Npm resolve
  • Native mini program pattern
  • Vue pattern
  • Mult Plugins
  • Custom compiler
  • Native mini program component
  • Component Npm resolve
  • Wechatwebdevtools control

Installing

use npm for installing wxa. npm i -g @wxa/cli

Usage

  1. basic build wxa build

  2. watch mode wxa build --watch

  3. build without cache and more detail log wxa build --no-cache --verbose

  4. create new project with template, see template wxa create base projectname

  5. invoke wechatdevtools, windows need setup wechatwebdevtools in wxa.config.js

  • wxa cli open: open dev tools
  • wxa cli preview: preview project
  • wxa cli upload -m 'upload msg' --ver 'verion': upload project
  • wxa cli login: login tool, preview and upload command need login your wechat account

Configurations

core configs file is wxa.config.js, mostly like below:

const path = require('path');
const UglifyjsPlugin = require('@wxa/plugin-uglifyjs');
const ReplacePlugin = require('@wxa/plugin-replace');
let prod = process.env.NODE_ENV === 'production';
const envlist = []; // your env configurations

module.exports = {
    wechatwebdevtools: '/Applications/wechatwebdevtools.app', // path to your wechat dev tool
    resolve: {
        alias: {
            '@': path.join(__dirname, 'src'),
        },
    },
    use: ['babel', 'sass', 'stylus'],
    compilers: {
        sass: {
            // compiler options
        },
    },
    plugins: [
        new ReplacePlugin({
            list: envlist,
        }),
    ],
};

if (prod) {
    module.exports.plugins.push(new UglifyjsPlugin());
}

Editor

use vsCode to make coding more enjoyable. use vetur for beautify .wxa file. following vscode's configurations is recommended:

{
    "javascript.implicitProjectConfig.experimentalDecorators": true,
    "vetur.grammar.customBlocks": {
    "config": "json"
  },
  "vetur.validation.template": false,
  "eslint.enable": true
}

and also a list of eslint configs:

{
    "extends": [
        "./node_modules/eslint-config-google/index.js"
    ],
    "root": true,
    "env": {
        "commonjs": true,
        "es6": true,
        "node": true
    },
    "parser": "vue-eslint-parser",
    "parserOptions": {
        "parser": "babel-eslint",
        "ecmaFeatures": {
            "experimentalObjectRestSpread": true
        },
        "ecmaVersion": 2017,
        "sourceType": "module"
    },
    "rules": {
        "vue/valid-template-root": "off",
        "no-const-assign": "warn",
        "valid-template-root": "off",
        "no-this-before-super": "warn",
        "no-undef": "warn",
        "no-unreachable": "warn",
        "no-unused-vars": "warn",
        "constructor-super": "warn",
        "valid-typeof": "warn",
        "one-var": "warn",
        "max-len": "off",
        "no-trailing-spaces": "off",
        "require-jsdoc": "warn",
        "camelcase": "warn",
        "no-invalid-this": "warn",
        "new-cap": "warn",
        "guard-for-in": "warn"
    }
}

Template

  1. Base Template

Component

wxa can resolve component in npm folder. you can easily import com from npm.

// in your page's config.json
{
    "usingComponents": {
        "counting": "@wxa/ui/src/components/counting"
    }
}

output mostly like this:

{
    "usingComponents": {
        "counting": "./../npm/@wxa/ui/src/components/counting"
    }
}

and wxa-ui is coming soon.

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.