Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected output path #3000

Open
stebogit opened this issue Jun 9, 2021 · 0 comments
Open

Unexpected output path #3000

stebogit opened this issue Jun 9, 2021 · 0 comments

Comments

@stebogit
Copy link

stebogit commented Jun 9, 2021

  • Laravel Mix Version: v6.0.19
  • Node Version: v16.2.0
  • NPM Version: v7.13.0
  • OS: macOS BigSur (v11.1)

Description:

I want to build two sets of JS files, one for the FE inside the (default) /public folder, the other for the BE inside a different folder, specifically /resources/scripts

Steps To Reproduce:

This is my webpack.mix.js:

const mix = require('laravel-mix');

mix
    .js('resources/js/main.js', 'public/js')
    .js('resources/js/contours/index.js', 'public/js/contours.js')
    .react()
    .sass('resources/sass/styles.scss', 'public/css')
    .sass('resources/sass/contours.scss', 'public/css/contours.css')
    .js('resources/scripts/contouring/src/index.js', 'resources/scripts/contouring/build/contouring.js')
;

The contouring.js file always ends up created inside the /public folder, regardless of the output path I use

┌─────────────────────────────────────────────────────────────────────────────┬───────────┐
│                                                                        File │ Size      │
├─────────────────────────────────────────────────────────────────────────────┼───────────┤
│                                                             /js/contours.js │ 1.92 MiB  │
│                                                                 /js/main.js │ 1.08 MiB  │
│                           /resources/scripts/contouring/build/contouring.js │ 1.65 MiB  │ <--
│                                                            css/contours.css │ 14.1 KiB  │
│                                                              css/styles.css │ 178 KiB   │
│   images/vendor/leaflet/dist/layers-2x.png?8f2c4d11474275fbc1614b9098334eae │ 1.23 KiB  │
│      images/vendor/leaflet/dist/layers.png?416d91365b44e4b4f4777663e6f009f3 │ 696 bytes │
│ images/vendor/leaflet/dist/marker-icon.png?2b3e1faf89f94a4835397e7a43b4f77d │ 1.43 KiB  │
└─────────────────────────────────────────────────────────────────────────────┴───────────┘

I tried the following but the output is always the same

.js('...index.js', '../resources/scripts/contouring/build/contouring.js')
.js('...index.js', '/../resources/scripts/contouring/build/contouring.js')
.js('...index.js', './../resources/scripts/contouring/build/contouring.js')
.js('...index.js', 'public/../resources/scripts/contouring/build/contouring.js')
.js('...index.js', 'resources/../../resources/scripts/contouring/build/contouring.js')

The public folder seems to be used by default even if you don't specify it in the output path, so the output is the same even with:

mix
    .js('resources/js/main.js', 'js')
    .js('resources/js/contours/index.js', 'js/contours.js')
    .react()
    .sass('resources/sass/styles.scss', 'css')
    .sass('resources/sass/contours.scss', 'css/contours.css')
    .js('resources/scripts/contouring/src/index.js', 'resources/scripts/contouring/build/contouring.js');

Setting the public path to the project root would produce the expected result for the specified built files, however the vendor images and the mix-manifest.json file would be generated in the root folder, which is not OK:

mix
    .setPublicPath('/')
    .js('resources/js/main.js', 'public/js')
    .js('resources/js/contours/index.js', 'public/js/contours.js')
    .react()
    .sass('resources/sass/styles.scss', 'public/css')
    .sass('resources/sass/contours.scss', 'public/css/contours.css')
    .js('resources/scripts/contouring/src/index.js', 'resources/scripts/contouring/build/contouring.js')
;
┌─────────────────────────────────────────────────────────────────────────────┬───────────┐
│                                                                        File │ Size      │
├─────────────────────────────────────────────────────────────────────────────┼───────────┤
│                                                      /public/js/contours.js │ 1.92 MiB  │ <-- now `public/...`
│                                                          /public/js/main.js │ 1.08 MiB  │
│                           /resources/scripts/contouring/build/contouring.js │ 1.65 MiB  │
│   images/vendor/leaflet/dist/layers-2x.png?8f2c4d11474275fbc1614b9098334eae │ 1.23 KiB  │
│      images/vendor/leaflet/dist/layers.png?416d91365b44e4b4f4777663e6f009f3 │ 696 bytes │
│ images/vendor/leaflet/dist/marker-icon.png?2b3e1faf89f94a4835397e7a43b4f77d │ 1.43 KiB  │
│                                                     public/css/contours.css │ 14.1 KiB  │
│                                                       public/css/styles.css │ 178 KiB   │
└─────────────────────────────────────────────────────────────────────────────┴───────────┘

I'd argue that the output path should define the exact output of the built asset relatively to the public folder (whatever that is), therefore ../ in the output path should allow to write at the same level of the public folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant