Git Product home page Git Product logo

Comments (6)

Southclaws avatar Southclaws commented on June 27, 2024 1

Yeah that's how it was, I couldn't get it to work at all unfortunately.

from parcel-namer-rewrite.

ol-loginov avatar ol-loginov commented on June 27, 2024 1

Ok, there is the branch for this issue
https://github.com/ol-loginov/parcel-namer-rewrite-issues/tree/12

There are 2 issues:

  1. Plugin uses file name returned by default namer. And as long as your "myscript.js" is not entry point - it's named by entry bundle. That's why it get name "404.js" (because bundle is constructed from 404.html) and ignored by rewrite rules.
  2. And if you add this file as entry (see package.json/targets/default/source) - you won't get the desired result, because the first rule match will be used: "(.*).js". To match "myscript.js", one should move this rule to first position in packages.json

After both of this points has been taken into account - you'll got what you need. You may find the example in that branch.

from parcel-namer-rewrite.

ol-loginov avatar ol-loginov commented on June 27, 2024

Nothing has changed. It should inside root element, like this:

{
  // ...
  "parcel-namer-rewrite": {
    "chain": "@parcel/namer-default",
    "rules": {
      "(.*).css": "assets-rewrite/css/$1{.hash}.css",
      "(.*).js": "assets-rewrite/js/$1{.hash}.js",
      "(.*).(jpg|png|gif|svg|webp|avif)": "assets/img1/$1.$2"
    }
  },
  // ....
}

from parcel-namer-rewrite.

kasapvictor avatar kasapvictor commented on June 27, 2024

I checked from your repo, not work
Added myscript.js to 404.html, and after build myrewrite/js/myscript.js does not exist

Screen
https://share.cleanshot.com/VxNmt0

from parcel-namer-rewrite.

kasapvictor avatar kasapvictor commented on June 27, 2024

02-06-2022-15-12-04-PhpStorm

It seems to work as it should, but the file is empty inside =/

Работает как надо вроде бы, но файл пустой внутри =/

from parcel-namer-rewrite.

ol-loginov avatar ol-loginov commented on June 27, 2024

This is because of optimization. Unused function test has been thrown away.

You should "exports" stuff that you need outside the file. For example, call a function, use exports or assign attribute to global (like in "standalone.js" in repo)

I've changed the branch to simplify example.

from parcel-namer-rewrite.

Related Issues (12)

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.