webpack-encore: Example giving in documentation does not work on windows

When following the first example in documentation you will end up with this error on windows

Error: Cannot determine how to prefix the keys in manifest.json. Call Encore.setManifestKeyPrefix() to choose what path (e.g. build/) to use when building your manifest keys. This is caused by setOutpu tPath() and setPublicPath() containing paths that don’t seem compatible.

This is reproduce able by creating an empty directory and following:

  1. execute $ yarn add @symfony/webpack-encore --dev
  2. create webpack.config.js file with contents found on http://symfony.com/doc/current/frontend/encore/simple-example.html
  3. creating assets/js/main.js & assets/css/global.scss
  4. execute ./node_modules/.bin/encore dev

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

Temporary fix for Windows environment:

Encore
// directory where all compiled assets will be stored
    .setOutputPath('web/build')

    // Windows??? <---------------------------
    .setManifestKeyPrefix('/build')

    // what's the public path to this directory (relative to your project's document root dir)
    .setPublicPath('/build')

    // empty the outputPath dir before each build
    .cleanupOutputBeforeBuild()
    // ...

At least this one is worked for me. @DaRamirezSoto Can you confirm, that this workaround is ok?

@Alestaan Hi,

I am executing this command:

node_modules\.bin\encore dev

@Alestaan Try npm instead of yarn

@vdjagilev Hi,

Oh i see now … so i shouldn’t use the yarn run encore dev command right ?

But shouldn’t the yarn run command be supported for the watch ? (i’m just asking, i’m curious about it)

Anyway, thanks !!

This makes sense - some of the path comparisons are certainly choking on the \ paths from Windows. We need to setup appveyor (it should be activated, but we don’t have any config for it yet). That should show us the errors and they’ll be easy to fix 😃.