Giter VIP home page Giter VIP logo

presswind-assets's Introduction

Presswind Vite JS Assets helpers for WordPress

This code give you the ability to use methods of the Presswind directly in your theme for use Vite JS.

Find the package on Packagist

PWVite

port - default 3000
path - from your theme root
position front|admin|editor - default front
is_ts - default false
is_plugin true|false - default false - for search assets in plugin folder
instead of theme folder
slug - handle - default presswind-script
is_https - default true - for https or http
main_file - default main - file name without extension

use PressWind\PWVite;

// use with named parameters for more readability

// in theme
// 1 - search dist folder in root theme
PWVite::init(port: 3000, path: '');

// 2 - search admin/dist folder in root theme
PWVite::init(port: 4444, path: 'admin', position: 'admin', is_ts: false);

// in plugin

// 3 - search dist folder in plugin test-plugin (from index.php root plugin)
PWVite::init( port: 7777, path: 'test-plugin/', plugin_path: __FILE__, slug:
'plugin-test' );

Preload fonts

PWVite::init()->setPreloadFont();

PWAssets

use PressWind\PWAssets;

// for css
PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toFront();
PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toBack();
PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toBlock();
PWAsset::add('my-css', get_template_directory_uri().'/assets/style.css')->dependencies([])->media('all')->version('1.0.0')->toLogin();


// for js
PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->module()
    ->toFront()
    ->withInline('console.log("hello world")');

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->noModule()
    ->toFront();

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->async()
    ->inFooter()
    ->toFront();

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->defer()
    ->inFooter()
    ->toFront();

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->defer()
    ->inFooter()
    ->toBack();

PWAsset::add('my-js', get_template_directory_uri().'/assets/js/app.js')
    ->dependencies(['jquery'])
    ->version('1.0.0')
    ->defer()
    ->inFooter()
    ->toBlock();

presswind-assets's People

Contributors

ipatate avatar

Stargazers

 avatar Damien Chantelouve avatar

Watchers

 avatar

presswind-assets's Issues

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.