Giter Club home page Giter Club logo

parcel-plugin-structurize's Introduction

parcel-plugin-structurize

npm (tag) checks

A Parcel plugin that lets you customize your output (dist) directory folder structure.

If you โค๏ธ this plugin and want to support, you can buy me a coffee!

Buy Me A Coffee

๐Ÿ—ƒ Table of Contents

๐Ÿค” Why?

When building for production, Parcel outputs the build in a flat structure. In some cases, we might need a particular structure for the built output.

This plugin lets you organize every file output by Parcel by matching and moving assets into your desired structure. It also updates all references in every file to ensure that the output is ready for consumption with your custom structure.

Advantages of using the plugin:

  • Supports excellent and fine-grained configuration for all use cases out of the box using glob pattern matching
  • Super fast and rapid restructuring means you do not need to worry about a massive overload in build times.
  • Respects publicUrl passed to Parcel bundler while restructuring the folder.
  • Respects the outDir passed to Parcel bundler and only restructures files within.
  • Sensible defaults to get you up and running quickly.

๐Ÿ”Œ Installation

Installation is straight forward using NPM or Yarn:

# Using NPM
npm install --save-dev parcel-plugin-structurize

# Using Yarn
yarn add -D parcel-plugin-structurize

๐Ÿš› Migrating from 1.x

Migrating from v1 to v2 of the plugin is super simple.

In your project, first upgrade the plugin:

yarn upgrade [email protected]

Then upgrade the configuration in package.json:

# package.json file
{
    "parcel-plugin-structurize": {
-        "scripts": {
-            "match": "*.{js,js.map}",
-            "folder": "js"
-        },
-        "styles": {
-            "match": "*.{css,css.map}",
-            "folder": "css"
-        },
-        "assets": {
-            "match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm}",
-            "folder": "assets"
-        }
+        "rules": [
+            {
+                "match": "*.js",
+                "folder": "js",
+            },
+            {
+                "match": "*.css",
+                "folder": "css",
+            },
+            {
+                "match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm}",
+                "folder": "assets",
+            },
+        ],
    }
}

๐Ÿƒโ€โ™€๏ธ Usage

There are two ways to configure the plugin:

  • Adding the parcel-plugin-structurize key to package.json.
// package.json
{
    "parcel-plugin-structurize": {
        "rules": [
            {
                "match": "*.js",
                "folder": "scripts"
            },
            {
                "match": "*.{jpg,png,gif,svg}",
                "folder": "images"
            }
        ]
    }
}
  • Via a parcel-plugin-structurize.json file in your project root (right next to your package.json).
// parcel-plugin-structurize.json
{
    "rules": [
        {
            "match": "*.js",
            "folder": "scripts"
        },
        {
            "match": "*.{jpg,png,gif,svg}",
            "folder": "images"
        }
    ]
}

Note: This plugin runs ONLY in parcel build or when NODE_ENV=production, since the use-case of running it in watch, serve or NODE_ENV=development is not compelling enough.


๐Ÿ›  Configuration

The plugin allows for fine-grained configuration options to ensure proper customization of the output directory.

Options

The configuration includes the following options:

  • rules

    Structurizer

    An array of objects which are called Structurizers.

  • verbose

    boolean

    Whether to enable verbose logging or not.

  • displayAssetsMap

    boolean

    Whether to display the generated assets map or not. This only comes into effect if verbose is true.

Disable plugin

You can disable the plugin by two means:

  • Set rules attribute in your config to false.
  • Set environment variable PARCEL_PLUGIN_STRUCTURIZE to false. Ex:
PARCEL_PLUGIN_STRUCTURIZE=false parcel build src/index.html

๐Ÿงฑ Structurizer

Structurizer is a rule that contains match patterns and the target.

type Config = {
    match: string;
    folder: string;
    flatten?: boolean;
};
  • match

    string

    A glob pattern to match file names and group them to a folder.

  • folder

    string

    The folder to place the files in. Can contain nested folders (ex: scripts/vendors, images/vectors/user/avatar)

  • flatten

    boolean

    For nested files, whether to flatten them to the output folder or not.

You can provide as many Structurizers in your configuration file. The plugin ships with sensible defaults.

// default config
{
    "verbose": false,
    "rules": [
        {
            "match": "*.js",
            "folder": "js",
            "flatten": false
        },
        {
            "match": "*.css",
            "folder": "css",
            "flatten": false
        },
        {
            "match": "*.{jpg,jpeg,jpeg2,png,gif,svg,bmp,webp}",
            "folder": "assets",
            "flatten": false
        }
    ]
}

โ—๏ธ Gotchas

  1. The order of the Structurizers matter if you want to target a glob and a file ending with the same extension. To better illustrate this, let's consider the following files in your output directory:

    • index.html
    • contact.html
    • about.html

    If you want to move all HTML files into a folder called app, except the index.html then you need to keep in mind the order of the Structurizers.

# The following will produce the desired results
+ Correct
[
    {
        "match": "index.html",
        "folder": "."
    },
    {
        "match": "*.html",
        "folder": "app"
    }
]

# And the following will result in your `index.html` to be placed inside the `app` directory as well
- Incorrect
[
    {
        "match": "*.html",
        "folder": "app"
    },
    {
        "match": "index.html",
        "folder": "."
    }
]
  1. You should NOT add any structurizer rules for .map files as the plugin automatically resolves and restructures the sourcemap files to reside in the same directory as its parent. This can cause unintended side-effects.

๐Ÿ  Contributing

To get the project up and running, clone it and then run the following command:

yarn bootstrap

It will install all packages, link dependencies and set everything up. To start the dev server:

yarn dev

To build the bundle, simply run:

yarn build

Bundling

Bundles watch for changes to the plugin and rebuild with Parcel bundler, causing the plugin to trigger. Once you have the plugin running in dev mode, you can run the following command for the bundles:

(cd __tests__/bundle && yarn dev)

Testing

To test you can run:

yarn test:watch

Bugs and issues

Please report any bugs here. For any questions feel free to create an issue.

parcel-plugin-structurize's People

Contributors

dependabot[bot] avatar nicolasreibnitz avatar samrith-s avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

parcel-plugin-structurize's Issues

Error: ENOENT: no such file or directory

I have a following build script:
"build": "parcel build index.html"
Added following to package.json

  "parcel-plugin-structurize": {
    "scripts": {
      "match": "*.{js,js.map}",
      "folder": "js"
    },
    "styles": {
      "match": "*.{css,css.map}",
      "folder": "css"
    },
    "assets": {
      "match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm}",
      "folder": "assets"
    }
  }

Get following error on build

(node:11712) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'C:\Users\User\Downloads\vue\vue\dist\C:\Users\User\Downloads\vue\vue\index.html'
    at Object.openSync (fs.js:451:3)
    at Object.readFileSync (fs.js:351:35)
    at markupFiles.map.file (C:\Users\User\Downloads\vue\vue\node_modules\parcel-plugin-structurize\src\index.js:41:38)
    at Array.map (<anonymous>)
    at Bundler.Structurize.bundler.on (C:\Users\User\Downloads\vue\vue\node_modules\parcel-plugin-structurize\src\index.js:39:45)
    at Bundler.emit (events.js:182:13)
    at Bundler.bundle (C:\Users\User\AppData\Roaming\npm\node_modules\parcel-bundler\src\Bundler.js:361:12)
    at process.internalTickCallback (internal/process/next_tick.js:77:7)
(node:11712) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:11712) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

[๐Ÿšง] v2 - Roadmap

When I first created this plugin over a year ago, I had no plans to maintain it. It was just something to fulfil a requirement at work.

This project is doing reasonably well, and though I don't provide regular updates, I am keen on giving it a complete revamp. This issue will be the point of discussion for everything pertaining to v2 of this plugin.

Releases

Foundation

The plugin now uses Typescript. This choice has been made keeping in mind the number of people making the switch to it and also in terms of maintainability and code discoverability.

As of 19/08/2020, the plugin engine support is currently:

"node": ">=12"

The previous version supported up to node@v8. If there is a strong enough case, I might still consider adding support for node@v10.

v2 Feature List

Support user-defined structures โœ…

Users will have fine-grained control over where certain files go and can group using a multitude of options.
Example:

[
	{
		"files": ".{jpg,png,gif,bmp,webp}",
		"folder": "images"
	},
	{
		"files": "*.svg",
		"folder": "vectors"
	}
]
Configuration file โœ…

Configuration using parcel-structurize.json or parcel-plugin-structurize key in package.json. This will help the user declutter package.json. The plugin will still ship with sane defaults to power zero-config integration.

Rework file targeting to enable multiple different sources of inputs โœ…

Remove the restriction of the plugin wherein it acts only on .html input sources. If there are no .html input sources, there is a lot of redundant code that runs. This rework should also make the plugin faster.

Better logging โœ…

Provide a map of all the resources changes upon completion. Right now user sees no information about updates to the output.

Contributions & Testing

To help test this, simple clone the repository and checkout to the v2 branch (it is already the default branch). To test it out in your project, you can run:

yarn add -D parcel-plugin-structurize@next

Bugs

To report bugs please use the v2 bug report template.

Dropped features

Custom tags

With the new configuration users can provide tags that the plugin should target Tags can be any valid HTML selector.
Example:

[
	{
		"files": ".{css,svg}",
		"folder": "assets",
		"source": "link[rel='stylesheet'], img[src*='.svg']"
	}
]

The plugin no longer iterates over HTML files to find and replace instances. This also means JSDOM is no longer a dependency.

Enable use of either globs or regexes

The files option in the new configuration will be able to accept glob patterns or regexes for more fine-tuning.
Example:

[
	{
		// glob match - Selects all CSS and SVG files
		"files": ".{css,svg}",
		"folder": "assets"
	},
	{
		// regex match - Selects all files with names <file-name>.vendor.js,
		"files": /(vendor\.js)$/,
		"folder": "vendor"
	}
]

Glob pattern already allows specifying complicated matches. Regex support is hence dropped.

[๐Ÿ›] Bug: Corrupted images

Describe the bug

I installed the plugin in one of my test projects and works ok for css, js, but it corrupts all the images I have in my project. The size of the (image) files are almost double in size after I run the build task.

Error messages

no error messages in the console

Expected behavior

the content of image files should be preserved

Screenshots

n.a.

Information

  • Package version: 2.1.2
  • Node version: 12.18.0

Additional context

n.a.

CSS path in index.html is not set correctly (missing directory)

Hi there,

I am facing an issue when running "parcel build". Apparently the paths required to correctly reference CSS stylesheets are not set correctly within the html file.

Means, if I run

parcel build src/index.html

with the following config added to my package.json

  "devDependencies": {
    "parcel-bundler": "^1.12.5",
    "parcel-plugin-clean-dist": "^0.0.6",
    "parcel-plugin-structurize": "^2.4.4",
    "sass": "^1.34.0"
  },
"parcel-plugin-structurize": {
  "verbose": true,
  "displayAssetsMap": true,
  "rules": [
    {
      "match": "*.{css,css.map}",
      "folder": "css"
    },
    {
      "match": "*.{js,js.map}",
      "folder": "js"
    },
    {
      "match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm,webp}",
      "folder": "img"
    }
  ]
}

I expect my index.html to be rendered with the following references to *.css and *.js

<link rel="stylesheet" href="/css/main.bb27b9fc.css">
...
<script src="/js/main.95ec2e8c.js"></script>

instead I am getting the following generated, JS looks fine but CSS is not referenced correctly (missing the css/ folder)

<link rel="stylesheet" href="/main.bb27b9fc.css">
...
<script src="/js/main.95ec2e8c.js"></script>

My output from the build command looks like this

npm run build-prod

> [email protected] build-prod
> parcel build src/index.html

โ ‹ Building...

โœจ  Built in 2.36s.

dist/main.95ec2e8c.js         1.24 KB    2.00s
dist/main.bb27b9fc.css.map      969 B      2ms
dist/main.95ec2e8c.js.map       875 B      0ms
dist/index.html                     786 B      8ms
dist/main.bb27b9fc.css          754 B    1.71s
  
  parcel-plugin-structurize
  Config: [AbsolutePathToProject]/package.json

  Assets Map:
  {
  '/index.html': {
    source: '[AbsolutePathToProject]/dist/index.html',
    destination: null,
    replacer: null,
    mapFile: false,
    dependents: [ '/main.95ec2e8c.js' ],
    config: undefined
  },
  '/main.95ec2e8c.js': {
    source: '[AbsolutePathToProject]/dist/main.95ec2e8c.js',
    destination: '[AbsolutePathToProject]/dist/js/main.95ec2e8c.js',
    replacer: '/js/main.95ec2e8c.js',
    mapFile: false,
    dependents: [ '/main.95ec2e8c.js.map', '/main.bb27b9fc.css' ],
    config: { match: '*.{js,js.map}', folder: 'js' }
  },
  '/main.95ec2e8c.js.map': {
    source: '[AbsolutePathToProject]/dist/main.95ec2e8c.js.map',
    destination: '[AbsolutePathToProject]/dist/js/main.95ec2e8c.js.map',
    replacer: '/js/main.95ec2e8c.js.map',
    mapFile: true,
    dependents: null,
    config: { match: '*.{js,js.map}', folder: 'js' }
  },
  '/main.bb27b9fc.css': {
    source: '[AbsolutePathToProject]/dist/main.bb27b9fc.css',
    destination: '[AbsolutePathToProject]/dist/css/main.bb27b9fc.css',
    replacer: '/css/main.bb27b9fc.css',
    mapFile: false,
    dependents: [ '/main.bb27b9fc.css.map' ],
    config: { match: '*.{css,css.map}', folder: 'css' }
  },
  '/main.bb27b9fc.css.map': {
    source: '[AbsolutePathToProject]/dist/main.bb27b9fc.css.map',
    destination: '[AbsolutePathToProject]/dist/css/main.bb27b9fc.css.map',
    replacer: '/css/main.bb27b9fc.css.map',
    mapFile: true,
    dependents: null,
    config: { match: '*.{css,css.map}', folder: 'css' }
  }
}

  Structurization complete. Modified 4 files in 6ms
  
   - Moved 2 files to dist/js
   - Moved 2 files to dist/css
  
  If you loved the plugin, do consider starring the repository:
  https://github.com/samrith-s/parcel-plugin-structurize
  
  Think something could be improved? Create an issue on our repository:
  http://bit.ly/parcel-plugin-structurize-feature-request

Any idea how this happened? Am I doing something wrong here?

Thanks a lot and take care,
best,
Jules

illegal read operation error

On Windows, running https://github.com/chrisdmacrae/parceleventy with structurize defaults, and getting this error.

(node:24340) UnhandledPromiseRejectionWarning: Error: EISDIR: illegal operation on a directory, read
    at Object.readSync (fs.js:493:3)
    at tryReadSync (fs.js:332:20)
    at Object.readFileSync (fs.js:369:19)
    at allStyles.forEach (D:\Workspace\test\node_modules\parcel-plugin-structurize\src\structurers\assets.structurize.js:35:38)
    at Proxy.forEach (<anonymous>)
    at markups.forEach (D:\Workspace\test\node_modules\parcel-plugin-structurize\src\structurers\assets.structurize.js:27:37)
(node:24340) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting
 a promise which was not handled with .catch(). (rejection id: 1)
(node:24340) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with
a non-zero exit code.

[โ”] Question: Directory structure is not being followed.

This is my first time ever opening an issue, so I hope I am doing this correctly and providing enough feedback ๐Ÿ‘

Question

I followed the usage instructions as provided. But the folders I outlined in parcel-plugin-structurize.json are not being moved/copied over on npm run build command.

My Version Information:

  • Node version: v14.17.6
  • Npm version: 7.24.1
  • "parcel-plugin-structurize": "^2.4.4"
  • "parcel": "^2.0.0-rc.0",
// parcel-plugin-structurize.json
{
    "rules": [
        {
            "match": "*.css",
            "folder": "src/css"
        },
        {
            "match": "*.{jpg,png,gif,svg}",
            "folder": "src/icons"
        },
        {
            "match": "*.{jpg,png,gif,svg}",
            "folder": "src/images"
        },
        {
            "match": "*.js",
            "folder": "src/js"
        }
    ]
}

This is what my structure looks like https://i.imgur.com/oktrIjF.png

The expectation was/is that your plugin maintains the same structure after running the npm run build command. This is what it looks like:

  "scripts": {
    "dev": "npm-run-all --parallel dev:*",
    "dev:parcel": "parcel serve ./src/index.html",
    "dev:css": "tailwindcss -i src/css/tailwind.css -o src/css/styles.css -w",
    "build": "npm-run-all clean css parcel",
    "clean": "rm -rf dist/*",
    "css": "tailwindcss -i src/css/tailwind.css -o src/css/styles.css",
    "parcel": "parcel build src/index.html"
  },

After running npm run build, this is the resulting output https://i.imgur.com/q3GTLEk.png

Am I doing something wrong?

Public URL support

This is the build command: parcel static/market/css/base.scss with the following structurize config "styles": { "match": "*.{css,css.map}", "folder": "static/market/js" },
The Django app serves static folder on /static by default

Source map error: request failed with status 404
Resource URL: http://localhost:4000/static/market/css/base.css
Source Map URL: /base.css.map

brotli (.br) and gzip (.gz) files are getting deleted

I use parcel-plugin-compress to produce compressed files scripts.js to scripts.js.br and scripts.js.gz, it works well, but I wanted them to be structured like following:

dist/
   js/
     scripts.js
     scripts.js.br
     scripts.js.gz

While I build, those two compressed files are missing, If I remove this plugin and rebuild then I got those files back but I don't want a flat directory structure.

My package.json config:

"parcel-plugin-structurize": {
    "scripts": {
      "match": "*.{js,js.map,js.br,js.gz}",
      "folder": "js"
    },
    "styles": {
      "match": "*.{css,css.map,css.br,css.gz}",
      "folder": "css"
    }
  }

[๐Ÿ›] Bug: Plugin corrupts font files, PDFs

Describe the bug

When using parcel-plugin-structurize to move around font files and PDFs, the files end up corrupted. Files remain intact when project is built with PARCEL_PLUGIN_STRUCTURIZE=false.

Error messages

Chrome DevTools errors for font files:

18 Failed to decode downloaded font: <URL>
7 OTS parsing error: incorrect file size in WOFF header
OTS parsing error: Size of decompressed WOFF 2.0 is less than compressed size
OTS parsing error: Failed to convert WOFF 2.0 font to SFNT
OTS parsing error: incorrect entrySelector for table directory

Acrobat Pro DC error when opening PDF:

An error occurred while opening this document. This file is damaged and cannot be repaired.

Expected behavior

All files in the project should remain undamaged. :)

Information

"parcel-plugin-structurize": {
    "rules": [
      {
        "match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm,webp}",
        "folder": "static/images"
      },
      {
        "match": "*.js",
        "folder": "static/scripts"
      },
      {
        "match": "*.css",
        "folder": "static/styles"
      },
      {
        "match": "*.{ttf,otf,woff,woff2}",
        "folder": "static/fonts"
      },
      {
        "match": "*.pdf",
        "folder": "static/download"
      }
    ]
  }

[๐Ÿ›] Bug: wrong instruction

Look at + section. You have comma after "css", "js" and "assets"

# package.json file
{
    "parcel-plugin-structurize": {
-        "scripts": {
-            "match": "*.{js,js.map}",
-            "folder": "js"
-        },
-        "styles": {
-            "match": "*.{css,css.map}",
-            "folder": "css"
-        },
-        "assets": {
-            "match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm}",
-            "folder": "assets"
-        }
+        "rules": [
+            {
+                "match": "*.js",
+                "folder": "js",
+            },
+            {
+                "match": "*.css",
+                "folder": "css",
+            },
+            {
+                "match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm}",
+                "folder": "assets",
+            },
+        ],
    }
}

[๐Ÿ›] Bug: Some assets not properly referenced

Some of the assets are not properly referenced.

This is my parcel-plugin-structurize.json file:

{
    "rules": [
        {
            "match": "*.js",
            "folder": "js"
        },
        {
            "match": "*.css",
            "folder": "css"
        },
        {
            "match": "*.{jpg,jpeg,jpeg2,png,gif,svg,bmp,webp}",
            "folder": "images"
        }
    ]
}

Expected behavior

I have configured the plugin to move .css files to the directory css.

The files are moved appropriately, but when it is referenced from the HTML the directory is not taken into consideration. I have included a screenshot of the generated HTML to illustrate what I mean.

Screenshots

This is the generated HTML.

image

Information

  • Package version: 2.3.1
  • Node version: 12.5.0

Thanks for all your effort. I not very proficient in Javascript, sorry. Let me know if there is something I've missed.

[๐Ÿ›] Bug: Path to asset gets updated only the first time

Describe the bug

This is pretty straightforward: adding the same asset multiple times to an HTML file (for example) results in 404, because the path doesn't get updated globally.

<img src="image.svg" />
<img src="image.svg" />
<img src="image.svg" />

becomes

<img src="assets/image.c9a7e9b8.svg">
<img src="image.c9a7e9b8.svg">
<img src="image.c9a7e9b8.svg">

Error messages

None.

Expected behavior

The resulting index.html file should be updated globally:

<img src="assets/image.c9a7e9b8.svg">
<img src="assets/image.c9a7e9b8.svg">
<img src="assets/image.c9a7e9b8.svg">

Information

  • Package version: v2.4.0
  • Node version: v14.16.0

Additional context

Please find a minimal test case here: https://github.com/NicolasReibnitz/simple-parcel-structure-test.

[๐Ÿ›] Bug: no such file or directory

Describe the bug

  1. Checkout this repo: https://github.com/aivchen/html2
  2. yarn install
  3. yarn build

Error messages

  The plugin "parcel-plugin-custom-dist-structure" has encountered an error.
  
  Error: ENOENT: no such file or directory, open '/home/andrew/web/html/dist/1.html'

Expected behavior

Successful build without errors

Information

  • Package version: checked all 2.X.X versions
  • Node version: 15.8.0

Support for custom asset types

It appeared to me that I could add a custom file type handler by simply incorporating the following into my package.json file like so:

"parcel-plugin-structurize": {
    "fonts": {
            "match": "*.{eto,woff,ttf}",
            "folder": "fonts"
        }
}

Is there a way to extend structurize to support abitrary file types?

UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory

While building I got the following warning:

(node:6268) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open 'D:\projects\_draft\boilerplate-par
cel-master\dist\style.8f0dceae.css'

The file style.8f0dceae.css has been moved to dist/css/ by this plugin and at the same time it's looking for the same file in dist/ folder, and it says it's missing.

[โ”] Question: update relative paths in all html files

Question

I am missing some configuration in order to get all html files updated with relative paths?

My configuration is:

	"parcel-plugin-structurize": {
		"rules": [
      {
				"match": "*.html",
				"folder": "."
			},
			{
				"match": "*.js",
				"folder": "js"
			},
			{
				"match": "*.css",
				"folder": "css"
			},
			{
				"match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm}",
				"folder": "img"
			}
		]
	},

I am running the build command, index.html is updated to relative css,js and images path but no other html files in the src folder.

these are my scripts:

	"scripts": {
		"postcss:watch": "postcss src/assets/css/index.pcss -o src/assets/css/index.css --env development -w",
		"postcss:build": "postcss src/assets/css/index.pcss -o src/assets/css/index.css --env production",
		"parcel:serve": "parcel src/index.html",
		"parcel:watch": "parcel watch src/*.html",
		"parcel:build": "parcel build src/*.html --detailed-report",
		"clean": "rm -rf dist .cache",
		"build": "npm-run-all -s clean postcss:build parcel:build",
		"start": "npm-run-all -s clean -p postcss:watch parcel:serve"
	},

The result is index file updated with relative paths but not other html files.

Information

  • Package version: ^2.3.2
  • Node version: 12

Path resolving doesn't work

It's almost same issue as #12 and #14.

My src/ directory is

src/
  css
    index.css
  js
    index.js
  pages
    index.html

and build it, then,

build/
  css
    css.hash.css
  js
    js.hash.js
  pages
    index.html

The paths to assets(css and js) in index.html is flat path such like <link rel="stylesheet" href="css.hash.css" /> and <script src="js.hash.js"></script>. It doesn't resolve path.

Configuration

"parcel-plugin-structurize": {
        "scripts": {
            "match": "*.{js,js.map}",
            "folder": "js"
        },
        "styles": {
            "match": "*.{css,css.map}",
            "folder": "css"
        },
        "assets": {
            "match": "*.{png,svg,jpg,jpg2,jpeg,gif,bmp,webm}",
            "folder": "assets"
        }
    }

Windows 10 Build

Hello,

When I run "parcel build ./src/**/*.html" and parcel-plugin-structize is configured, it also rewrites my HTML files in the src folder but only on Windows 10, not on Mac or Linux.

Do you already have the problem? Do you have a solution?

Thank you for reading me and for your time :)

[parcel v2] Question:

This plugin is very useful to me, but it only supports parcel bundler, but it doesn't support parcel v2. I don't know when it will be supported? ๐Ÿ™Š

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.