bariscodefx/webpack-php

自动加载由webpack编译的javascript文件的加载器。

1.0.0 2023-05-21 14:37 UTC

This package is auto-updated.

Last update: 2024-09-21 17:34:27 UTC


README

自动加载由webpack编译的javascript文件的加载器。

示例用法

<?php

require_once "./vendor/autoload.php";

$webpack = new \bariscodefx\WebpackPHP\WebpackPHP("testdir/");
var_dump($webpack->asset('index.*\.js'));
var_dump($webpack->asset('main\.bundle.*\.js'));

输出

string(63) "<script type="text/javascript" src="testdir/index.bundle.2.js">"
string(67) "<script type="text/javascript" src="testdir/main.bundle.312453.js">"

您可以在视图模板中使用此功能。

<!DOCTYPE html>
<html>
    <head>
        <title>Foobar</title>
        <?= $webpack->asset('something\.bundle\.*\.js') ?>
...

使用样式

<!DOCTYPE html>
<html>
    <head>
        <title>Foobar</title>
        <?= $webpack->asset('something\.bundle\.*\.css', 'style') ?>