Giter Site home page Giter Site logo

Comments (9)

khalwat avatar khalwat commented on August 23, 2024 1

^ not forgotten!

from craft-twigpack.

khalwat avatar khalwat commented on August 23, 2024 1

Not yet, I apologize. I'll carve out some time this week or this weekend to get it addressed.

from craft-twigpack.

stereomyth avatar stereomyth commented on August 23, 2024 1

@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.

khalwat avatar khalwat commented on August 23, 2024

Thanks, will address

from craft-twigpack.

ugrupp avatar ugrupp commented on August 23, 2024

Is there currently any workaround for this?

from craft-twigpack.

stereomyth avatar stereomyth commented on August 23, 2024

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.

khalwat avatar khalwat commented on August 23, 2024

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.

khalwat avatar khalwat commented on August 23, 2024

@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.

hatzipanis avatar hatzipanis commented on August 23, 2024

Thanks for documenting this @khalwat, it fixed the issue for us.

from craft-twigpack.

Related Issues (20)

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.