Comments (9)
^ not forgotten!
from craft-twigpack.
Not yet, I apologize. I'll carve out some time this week or this weekend to get it addressed.
from craft-twigpack.
@khalwat Does your webpack setup product files even in dev mode?
I think the problem for me was that the files I am trying to load from manifest are created in memory by webpack so are not available in the filesystem (in dev). I had to set my basePath
to the webpack server (http://localhost:8080/
) rather than a folder.
from craft-twigpack.
Thanks, will address
from craft-twigpack.
Is there currently any workaround for this?
from craft-twigpack.
I got mine to work in dev mode by commenting out the path combining stuff. Might only work with my specific config though.
craft/vendor/nystudio107/craft-twigpack/src/helpers/Manifest.php
:
public static function getFileFromManifest(array $config, string $fileName, string $type = 'legacy'): string
{
try {
$path = self::getModuleEntry($config, $fileName, $type, true);
} catch (NotFoundHttpException $e) {
Craft::error($e->getMessage(), __METHOD__);
}
if ($path !== null) {
// only comment for dev mode
// $path = self::combinePaths(
// $config['localFiles']['basePath'],
// $path
// );
return self::getFileFromUri($path, null) ?? '';
}
return '';
}
from craft-twigpack.
So I (finally) started testing this, and it's working without issue for me. I think the difference might be that in my twigpack.php
I'm using an alias to point to the web root:
<?php
/**
* Twigpack plugin for Craft CMS 3.x
*
* Twigpack is the conduit between Twig and webpack, with manifest.json &
* webpack-dev-server HMR support
*
* @link https://nystudio107.com/
* @copyright Copyright (c) 2018 nystudio107
*/
/**
* Twigpack config.php
*
* This file exists only as a template for the Twigpack settings.
* It does nothing on its own.
*
* Don't edit this file, instead copy it to 'craft/config' as 'twigpack.php'
* and make your changes there to override default settings.
*
* Once copied to 'craft/config', this file will be multi-environment aware as
* well, so you can have different settings groups for each environment, just as
* you do for 'general.php'
*/
return [
// Global settings
'*' => [
// If `devMode` is on, use webpack-dev-server to all for HMR (hot module reloading)
'useDevServer' => false,
// The JavaScript entry from the manifest.json to inject on Twig error pages
'errorEntry' => '',
// Manifest file names
'manifest' => [
'legacy' => 'manifest-legacy.json',
'modern' => 'manifest.json',
],
// Public server config
'server' => [
'manifestPath' => '@webroot/dist/',
'publicPath' => '/',
],
// webpack-dev-server config
'devServer' => [
'manifestPath' => 'http://localhost:8080/',
'publicPath' => 'http://localhost:8080/',
],
// Local files config
'localFiles' => [
'basePath' => '@webroot/',
'criticalPrefix' => 'dist/criticalcss/',
'criticalSuffix' => '_critical.min.css',
],
],
// Live (production) environment
'live' => [
// Public server config
'server' => [
'manifestPath' => '@webroot/dist/',
'publicPath' => '/',
],
],
// Staging (pre-production) environment
'staging' => [
// Public server config
'server' => [
'manifestPath' => '@webroot/dist/',
'publicPath' => '/',
],
],
// Local (development) environment
'local' => [
// If `devMode` is on, use webpack-dev-server to all for HMR (hot module reloading)
'useDevServer' => true,
// The JavaScript entry from the manifest.json to inject on Twig error pages
'errorEntry' => 'app.js',
// webpack-dev-server config
'devServer' => [
'manifestPath' => 'http://localhost:8080/',
'publicPath' => 'http://192.168.10.10:8080/',
],
],
];
Note the use of @webroot here:
// Local files config
'localFiles' => [
'basePath' => '@webroot/',
'criticalPrefix' => 'dist/criticalcss/',
'criticalSuffix' => '_critical.min.css',
],
from craft-twigpack.
@stereomyth @ugrupp lmk how you go setting this via alias as described; I'm likely going to close the issue unless there is further discussion needed.
from craft-twigpack.
Thanks for documenting this @khalwat, it fixed the issue for us.
from craft-twigpack.
Related Issues (20)
- [FR] CSP nonce support HOT 7
- webpack-dev-server/HMR not working in Nitro setup HOT 3
- includeCriticalCssTags() returns empty HOT 1
- Hashes wrong (cache?) in production - ideas why? HOT 3
- Does update 1.2.4 removes the need for the styles.js workaround? HOT 1
- support chunks-webpack-plugin HOT 1
- missing "simplified version" of the config HOT 1
- Let me define a fallback CSS file for criticalcss HOT 1
- "modern" script not loaded when async is missing HOT 2
- Cannot load criticalcss if router file is used instead of a the specific template path in the CMS HOT 1
- Issues with twigpack cache on Heroku HOT 4
- Request to mix-manifest.json is malformed HOT 2
- Aliases like @webroot not working HOT 5
- ViteJS Support HOT 9
- Rendering templates with multiple getModuleUri calls is extremely slow after release v1.2.12 HOT 1
- ErrorException thrown when open_basedir restriction in effect HOT 7
- getModuleUri giving the correct URL to CSS but includeCssModule doesn't include the CSS on the page HOT 2
- Twigpack is stuck on where it thinks mix-manifest is located HOT 8
- 4.0.0 release HOT 4
- Craft 5 & Craft 4 out of beta HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from craft-twigpack.