parcel-namer-rewrite icon indicating copy to clipboard operation
parcel-namer-rewrite copied to clipboard

Add some examples to the readme

Open Jako opened this issue 3 years ago • 5 comments

Thanks for the nice and simple plugin. I never got the parcel-reporter-entries plugin to work, so I didn't get to test this plugin for a long time. Maybe you should add some real world examples to the readme. The following rules help me to structure the dist folder::

  "parcel-namer-rewrite": {
    "rules": {
      "(.*)\\.(css)": "css/$1.$2",
      "(.*)\\.(js)": "js/$1.$2",
      "(.*)\\.(woff2?)": "fonts/$1.$2",
      "(.*)\\.(svg|png|gif|jpg)": "img/$1.$2"
    }
  },

Jako avatar Sep 10 '21 06:09 Jako

Does it work with parcel2? Could you please show file package.json?

viktorkasap avatar Dec 05 '21 05:12 viktorkasap

This works with Parcel2.

{
…
  "scripts": {
    "start": "parcel src/*.html",
    "build": "parcel build src/*.html --no-source-maps --public-url ./",
    "clean": "rimraf dist"
  },
  "targets": {
    "app": {
      "distDir": "./dist/"
    }
  },
  "parcel-namer-rewrite": {
    "rules": {
      "(.*)\\.(css)": "css/$1.$2",
      "(.*)\\.(js)": "js/$1.$2",
      "(.*)\\.(woff2?)": "fonts/$1.$2",
      "(.*)\\.(svg|png|gif|jpg)": "img/$1.$2"
    },
    "silent": true
  },
  "devDependencies": {
    "@parcel/transformer-image": "^2.0.0",
    "@parcel/transformer-sass": "^2.0.0",
    "autoprefixer": "^10.3.7",
    "parcel": "^2.0.0",
    "parcel-namer-rewrite": "^2.0.0-rc.1",
    "postcss": "^8.3.9",
    "rimraf": "^3.0.2"
  },
…
}

Jako avatar Dec 06 '21 00:12 Jako

This works with Parcel2.

{
…
  "scripts": {
    "start": "parcel src/*.html",
    "build": "parcel build src/*.html --no-source-maps --public-url ./",
    "prebuild": "rimraf dist"
  },
  "targets": {
    "app": {
      "distDir": "./dist/"
    }
  },
  "parcel-namer-rewrite": {
    "rules": {
      "(.*)\\.(css)": "css/$1.$2",
      "(.*)\\.(js)": "js/$1.$2",
      "(.*)\\.(woff2?)": "fonts/$1.$2",
      "(.*)\\.(svg|png|gif|jpg)": "img/$1.$2"
    },
    "silent": true
  },
  "devDependencies": {
    "@parcel/transformer-image": "^2.0.0",
    "@parcel/transformer-sass": "^2.0.0",
    "autoprefixer": "^10.3.7",
    "parcel": "^2.0.0",
    "parcel-namer-rewrite": "^2.0.0-rc.1",
    "postcss": "^8.3.9",
    "rimraf": "^3.0.2"
  },
…
}

This will only work if you have .parcelrc config file in the project, right?

{
  "extends": "@parcel/config-default",
  "namers": [ "parcel-namer-rewrite" ]
}

viktorkasap avatar Dec 06 '21 03:12 viktorkasap

Yes, thats described in the readme of this plugin.

Jako avatar Dec 06 '21 06:12 Jako

Yes, thats described in the readme of this plugin.

You helped a lot. Thanks =)

But if the same lines are added to package.json, it will not work. Works only if there is a .pracelrc file...

viktorkasap avatar Dec 06 '21 06:12 viktorkasap