Git Product home page Git Product logo

webpack-laravel-mix-manifest's Introduction

Webpack Laravel Mix Manifest

Node.js Package Node.js CI version license downloads

A webpack plugin that generates Laravel framework compatible mix-manifest.json file.

If you are using webpack 2 or 3 then install version 1.x instead.

The plug-in version corresponding to the webpack version

webpack version plugin version
2.x or 3.x 1.0.x
4.x 2.1.x or v2.2
5.0 3.x - current branch

Use Case

If you are not using Laravel Mix to bundle your assets in Laravel php framework, and you still want to utilize mix() helper method, this plugin can help you in generating mix-manifest.json

Supported:

  • TypeScript
  • ECMAScript 2015+ or Babel
  • CommonJS

Installation

The plugin is available via npm:

npm install webpack-laravel-mix-manifest --save-dev

If you are using yarn:

yarn add webpack-laravel-mix-manifest --dev

Examples

Using the ES module (Babel) webpack configuration usage

import { WebpackLaravelMixManifest } from 'webpack-laravel-mix-manifest';

export default {
  plugins: [
    // Write out mix-manifest.json to build directory.
    new WebpackLaravelMixManifest(),
  ],
};

Example ๐Ÿ‘‰ ES module(Babel) Example

Using CommonJS webpack configuration usage

const { WebpackLaravelMixManifest } = require('webpack-laravel-mix-manifest');

module.exports = {
  plugins: [
    // Write out mix-manifest.json to build directory.
    new WebpackLaravelMixManifest(),
  ],
};

Example ๐Ÿ‘‰ CommonJS Example

Laravel usage

Assume that the generated public/mix-manifest.json content is:

{
  "/js/main.js": "/js/main-be4b86e10e835384d714.js"
}

Blade usage:

<script src="{{ mix('js/main.js') }}"></script>

Browser output:

<script src="/js/main-be4b86e10e835384d714.js"></script>

Configuration options

You can customize the name of the generated JSON file name.

new WebpackLaravelMixManifest('mix-manifest.json');

License

This package follows the MIT open source agreement.

webpack-laravel-mix-manifest's People

Contributors

ankurk91 avatar ava-cassiopeia avatar dependabot[bot] avatar julesjanssen avatar medz avatar prestancedesign avatar renovate[bot] 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

Watchers

 avatar  avatar  avatar

webpack-laravel-mix-manifest's Issues

Duplicated paths when using path based entries

Hi! Let me thank you for creating this plugin first of all ;)

I'm facing a "bug" using v2.2 and path based entries, it duplicates the path reference for some reason.

I'm using the following code:

const path = require('path');
const { WebpackLaravelMixManifest } = require('webpack-laravel-mix-manifest');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');

module.exports = {
    mode: 'none',
    entry: {
        'main': path.resolve(__dirname, '.../main.js'),
        'path/to/main': path.resolve(__dirname, '.../path/to/somewhere/else/main.js'),
    },
    output: {
        path: path.resolve(__dirname, 'dist'),
        filename: '[name]-[hash].js',
    },
    plugins: [
        new CleanWebpackPlugin,
        new WebpackLaravelMixManifest,
    ]
};

Gives the following output:

{
  "/main.js": "/main-3f663f8ee172ebfa8218.js"
  "/path/to/path/to/main.js": "/path/to/main-bd6aa1bfdc4dd1131a4b.js"
}

Note the difference when using an entry with the output at root of public path and when the output is nested in some path.

Everything else in the webpack process is working as expected except the manifest output, for this reason I'm guessing it could be a bug.

Thanks!

URL is not defined

Error:

95% emitting WebpackLaravelMixManifestReferenceError: URL is not defined
    at WebpackLaravelMixManifest.module.exports [as transform] (/var/www/portal-beta/node_modules/webpack-laravel-mix-manifest/src/transform.js:30:7)

Used in Webpack:

plugins: [ new WebpackLaravelMixManifest() ]

Suggestion:
Add this line at the top of file /src/transform.js

const URL = require('url').URL;

webpack-laravel-mix-manifest: 2.0.3
Node version: 6.11.3 (npm --v)
System: Ubuntu 16.0.4

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/codeql-analysis.yml
  • actions/checkout v4
  • github/codeql-action v3
  • github/codeql-action v3
  • github/codeql-action v3
.github/workflows/nodejs.yml
  • actions/checkout v4
  • actions/setup-node v4
.github/workflows/npmpublish.yml
  • actions/checkout v4
  • actions/setup-node v4
  • actions/checkout v4
  • actions/setup-node v4
npm
package.json
  • @types/jest ^29.0.0
  • @types/node ^20.0.0
  • jest ^29.0.0
  • prettier ^3.0.0
  • ts-jest ^29.0.0
  • typescript ^4.1.3
  • webpack ^5.51.1
  • webpack ^5.51.1

  • Check this box to trigger a request for Renovate to run again on this repository

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.