Skip to content

Gulp plugin that lets you create custom aliases for wecaht weapp

License

Notifications You must be signed in to change notification settings

echofly/gulp-weapp-alias

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Gulp Weapp Alias

Gulp plugin that lets you create custom aliases for wecaht weapp with an @alias rule. Supports .wxml, .wxss(less|scss), .js and .wxs file.

Install

  npm i gulp-weapp-alias -D

Usage

gulpfile.js

const { src, dest } = require('gulp');
const aliases = require('gulp-weapp-alias');

function aliasTask() {
    return src('src/*.{wxss|less|scss|wxml|js}')
        .pipe(aliases({
            '@Aliases': "path/to/your/folder",
        }))
        .pipe(dest('dist'));
}

the file before compilation

// .js
import * as Utils from '@Aliases/utils/base';
require('@Aliases/utils/base')
// .(wxss|less|scss)
@import '@Aliases/style/reset.less';

.bg {
  background-image: url('@Aliases/images/32821027.jpg');
}
// .wxml
<import src="@Aliases/wxs/index.wxs" />

<image src="@Aliases/images/32821027.jpg" mode="cover"></image>

will become:

// .js
import * as Utils from 'path/to/your/folder/utils/base';
require('path/to/your/folder/utils/base')
// .(wxss|less|scss)
@import 'path/to/your/folder/style/reset.less';

.bg {
  background-image: url('path/to/your/folder/images/32821027.jpg');
}
// .wxml
<import src="path/to/your/folder/wxs/index.wxs" />

<image src="path/to/your/folder/images/32821027.jpg" mode="cover"></image>

About

Gulp plugin that lets you create custom aliases for wecaht weapp

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published