generated from likesistemas/composer-empty
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GEST-712] Implementando Webpack Encore
- Loading branch information
1 parent
8e67601
commit 1fff281
Showing
12 changed files
with
174 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ desktop.ini | |
node_modules/ | ||
public/ | ||
assets/ | ||
webpack.config.js | ||
webpack.config.js | ||
tests/template-compile/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
namespace WebpackEncore; | ||
|
||
use Smarty; | ||
|
||
class SmartyTemplateIntegration { | ||
public static function addFunctions(Smarty $smarty, ReadEntrypoints $readEntrypoints) { | ||
$smarty->registerPlugin('function', 'webpack_encore_css', function ($params) use ($readEntrypoints) { | ||
return $readEntrypoints->getCssTags($params['name'] ?: 'app'); | ||
}); | ||
$smarty->registerPlugin('function', 'webpack_encore_js', function ($params) use ($readEntrypoints) { | ||
return $readEntrypoints->getJsTags($params['name'] ?: 'app'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
namespace Like\NomeDaLib\Tests; | ||
|
||
use WebpackEncore\ReadEntrypoints; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class ReadEntrypointsErrorsTest extends TestCase { | ||
public function testFileNotFound() { | ||
$readEntrypoints = ReadEntrypoints::get('inexistent-folder'); | ||
$this->assertEquals([], $readEntrypoints->getCss()); | ||
$this->assertEquals([], $readEntrypoints->getJs()); | ||
} | ||
|
||
public function testEmpty() { | ||
$readEntrypoints = ReadEntrypoints::get('tests/empty'); | ||
$this->assertEquals([], $readEntrypoints->getCss()); | ||
$this->assertEquals([], $readEntrypoints->getJs()); | ||
} | ||
|
||
public function testEmpty2() { | ||
$readEntrypoints = ReadEntrypoints::get('tests/empty2'); | ||
$this->assertEquals([], $readEntrypoints->getCss()); | ||
$this->assertEquals([], $readEntrypoints->getJs()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
namespace Like\NomeDaLib\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Smarty; | ||
use WebpackEncore\ReadEntrypoints; | ||
use WebpackEncore\SmartyTemplateIntegration; | ||
|
||
class SmartyTemplateIntegrationTest extends TestCase { | ||
public function testUseTemplate() { | ||
$readEntrypoints = ReadEntrypoints::get('tests/valid'); | ||
$smarty = new Smarty(); | ||
SmartyTemplateIntegration::addFunctions($smarty, $readEntrypoints); | ||
|
||
$smarty->addTemplateDir(__DIR__ . '/./template/'); | ||
$smarty->compile_dir = __DIR__ . '/./template-compile/'; | ||
$this->assertEquals('<html> | ||
<head> | ||
<title>Teste</title> | ||
<link href="/build/app.css" rel="stylesheet"> | ||
</head> | ||
<body> | ||
<script type="text/javascript" src="/build/runtime.js"></script><script type="text/javascript" src="/build/app.js"></script> | ||
</body> | ||
</html>', $smarty->fetch('index.tpl')); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"entrypoints": { | ||
"app": { | ||
"js": [], | ||
"css": [] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"entrypoints": { | ||
"app": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<html> | ||
<head> | ||
<title>Teste</title> | ||
{webpack_encore_css} | ||
</head> | ||
<body> | ||
{webpack_encore_js} | ||
</body> | ||
</html> |
File renamed without changes.