Giter Site home page Giter Site logo

peerigon / extract-loader Goto Github PK

View Code? Open in Web Editor NEW
317.0 15.0 74.0 778 KB

webpack loader to extract HTML and CSS from the bundle

License: The Unlicense

JavaScript 96.72% CSS 0.38% HTML 2.90%
webpack webpack-loader extract extract-text-webpack-plugin mini-css-extract-plugin

extract-loader's Introduction

extract-loader

webpack loader to extract HTML and CSS from the bundle.

Dependency Status Build Status Coverage Status

The extract-loader evaluates the given source code on the fly and returns the result as string. Its main use-case is to resolve urls within HTML and CSS coming from their respective loaders. Use the file-loader to emit the extract-loader's result as separate file.

import stylesheetUrl from "file-loader!extract-loader!css-loader!main.css";
// stylesheetUrl will now be the hashed url to the final stylesheet

The extract-loader works similar to the extract-text-webpack-plugin and the mini-css-extract-plugin and is meant as a lean alternative to it. When evaluating the source code, it provides a fake context which was especially designed to cope with the code generated by the html- or the css-loader. Thus it might not work in other situations.


Installation

$ npm install extract-loader --save-dev

Examples

Bundling CSS with webpack has some nice advantages like referencing images and fonts with hashed urls or hot module replacement in development. In production, on the other hand, it's not a good idea to apply your stylesheets depending on JS execution. Rendering may be delayed or even a FOUC might be visible. Thus it's still better to have them as separate files in your final production build.

With the extract-loader, you are able to reference your main.css as regular entry. The following webpack.config.js shows how to load your styles with the style-loader in development and as separate file in production.

module.exports = ({ mode }) => {
    const pathToMainCss = require.resolve("./app/main.css");
    const loaders = [{
        loader: "css-loader",
        options: {
            sourceMap: true
        }
    }];

    if (mode === "production") {
        loaders.unshift(
            "file-loader",
            "extract-loader"
        );
    } else {
        loaders.unshift("style-loader");
    }

    return {
        mode,
        entry: pathToMainCss,
        module: {
            rules: [
                {
                    test: pathToMainCss,
                    loaders: loaders
                },
            ]
        }
    };
};

You can even add your index.html as entry and reference your stylesheets from there. In that case, tell the html-loader to also pick up link:href:

module.exports = ({ mode }) => {
    const pathToMainJs = require.resolve("./app/main.js");
    const pathToIndexHtml = require.resolve("./app/index.html");

    return {
        mode,
        entry: [
            pathToMainJs,
            pathToIndexHtml
        ],
        module: {
            rules: [
                {
                    test: pathToIndexHtml,
                    use: [
                        "file-loader",
                        "extract-loader",
                        {
                            loader: "html-loader",
                            options: {
                                attrs: ["img:src", "link:href"]
                            }
                        }
                    ]
                },
                {
                    test: /\.css$/,
                    use: [
                        "file-loader",
                        "extract-loader",
                        {
                            loader: "css-loader",
                            options: {
                                sourceMap: true
                            }
                        }
                    ]
                },
                {
                    test: /\.jpg$/,
                    use: "file-loader"
                }
            ]
        }
    };
}

turns

<html>
<head>
    <link href="main.css" type="text/css" rel="stylesheet">
</head>
<body>
    <img src="hi.jpg">
</body>
</html>

into

<html>
<head>
    <link href="7c57758b88216530ef48069c2a4c685a.css" type="text/css" rel="stylesheet">
</head>
<body>
    <img src="6ac05174ae9b62257ff3aa8be43cf828.jpg">
</body>
</html>

Source Maps

If you want source maps in your extracted CSS files, you need to set the sourceMap option of the css-loader:

    {
        loader: "css-loader",
        options: {
            sourceMap: true
        }
    }

Options

There is currently exactly one option: publicPath. If you are using a relative publicPath in webpack's output options and extracting to a file with the file-loader, you might need this to account for the location of your extracted file. publicPath may be defined as a string or a function that accepts current loader context as single argument.

Example with publicPath option as a string:

module.exports = {
    output: {
        path: path.resolve("./dist"),
        publicPath: "dist/"
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    {
                        loader: "file-loader",
                        options: {
                            name: "assets/[name].[ext]",
                        },
                    },
                    {
                        loader: "extract-loader",
                        options: {
                            publicPath: "../",
                        }
                    },
                    {
                        loader: "css-loader",
                    },
                ],
            }
        ]
    }
};

Example with publicPath option as a function:

module.exports = {
    output: {
        path: path.resolve("./dist"),
        publicPath: "dist/"
    },
    module: {
        rules: [
            {
                test: /\.css$/,
                use: [
                    {
                        loader: "file-loader",
                        options: {
                            name: "assets/[name].[ext]",
                        },
                    },
                    {
                        loader: "extract-loader",
                        options: {
                            // dynamically return a relative publicPath based on how deep in directory structure the loaded file is in /src/ directory
                            publicPath: (context) => '../'.repeat(path.relative(path.resolve('src'), context.context).split('/').length),
                        }
                    },
                    {
                        loader: "css-loader",
                    },
                ],
            }
        ]
    }
};

You need another option? Then you should think about:


Contributing

From opening a bug report to creating a pull request: every contribution is appreciated and welcome. If you're planning to implement a new feature or change the api please create an issue first. This way we can ensure that your precious work is not in vain.

All pull requests should have 100% test coverage (with notable exceptions) and need to pass all tests.

  • Call npm test to run the unit tests
  • Call npm run coverage to check the test coverage (using istanbul)

License

Unlicense

Sponsors

extract-loader's People

Contributors

alqh avatar benurb avatar bogas04 avatar fabianonunes avatar goto-bus-stop avatar gpoitch avatar heptahedron avatar ipsips avatar jannikkeye avatar jhnns avatar jpommerening avatar meaku avatar munter avatar semantic-release-bot avatar siakaramalegos avatar sime avatar vseventer 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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

extract-loader's Issues

index-html example: ERROR in Unexpected token import @ multi main

The index-html example fails to run, or I might be missing something.

$ git clone [email protected]:peerigon/extract-loader.git
$ cd extract-loader/examples/index-html/
$ edit webpack.config.js # replace "lib" with "src"
$ npm init -y
$ npm install --save extract-loader webpack html-loader file-loader
$ webpack
Hash: e0221d2f5402e6af381f
Version: webpack 1.14.0
Time: 61ms
    Asset     Size  Chunks             Chunk Names
bundle.js  1.66 kB       0  [emitted]  main
   [0] multi main 40 bytes {0} [built] [1 error]
   [1] ./app/main.js 19 bytes {0} [built]
    + 1 hidden modules

ERROR in Unexpected token import
 @ multi main

loaderContext.loadModule API throw error when using with css-loader

webpack.config.js:
        rules: [{
            test: /\.css$/,
            use: [
                'to-string-loader',
                'extract-loader',
                'css-loader',
        ]

My demo:
image

**### index.csss:**
@import './common.css';
text {
    color: aliceblue;
    background-image: url('https:www.baidu.com');
}

**common.css:**
body {
    border: 1px solid orangered;
}
@import './page/page.css';

**page.css:**
input {
    padding-left: 19px;
    border: 1px solid orangered;
}
@import './style/index.css';

**style/index.css:**
text {
    color: fsdfa;
}

when run script npm run build:

Below are error message:

image


**My solution:**
function loadModule(filename) {
       + let splits = filename.split("!");
        + let stringRequest = undefined;
        + if (splits[1]) {
            + const cssLoaderPath = loaderContext.remainingRequest.split('!')[0];
            + if (cssLoaderPath) {
                + stringRequest = stringifyRequest(loaderContext, cssLoaderPath);
            }
            + const splittedPart = splits[1].match(/^(.*?)(\?.*)/);
            + singlePath = splittedPart ? splittedPart[1] : splits[1];
            + let filePath = path.join(loaderContext.context, singlePath);
           + if (!fs.existsSync(filePath) && singlePath !== stringRequest) {
                + splits[1] = JSON.parse(stringRequest);
            }
        }
       + filename = splits.join("!");
        return new Promise((resolve, reject) => {
            loaderContext.loadModule(filename, (error, src) => {
                if (error) {
                    reject(error);
                } else {
                    resolve(src);
                }
            });
        });
    }
 I found 'stringifyRequest' is not corret, shoud fix it base on current loaderContext.

Webpack 5.1.3 and PublicPath auto

Webpack: 5.1.3
extract-loader: 5.1.0

there's this PR webpack/webpack#11258 that was merged and released as part of Webpack 5.1.3 which changes the default publicPath option to auto.

and getPublicPath function that refers to the variable in this line

which result in require("./assets/styles/style.css") being resolved to <link rel="stylesheet" href="autoad70c8b2da42929dc855c3fd20c749b2.css"/>\n'

notice the auto.

I personally do not have any context on how this should be properly handled for extract-loader.
If any veteran would provide a direction I can make the changes and submit a PR.

for people that needs a quick fix, just explicitly provide the option of publicPath as empty string like so

          {
            loader: "extract-loader",
            options: {
              publicPath: "",
            }
          },

SyntaxError: Unexpected token export

Using the example with Node v8.15.0 produces the error SyntaxError: Unexpected token export
at node_modules/extract-loader/lib/extractLoader.js:81:28.

The line 81 is trying to parse the source:

module.exports = "<!DOCTYPE html>\n<html>\n    <head>\n        <link rel=\"style\" href=\"" + require("./index.css") + "\">\n    </head>\n    <body>\n              <img src=\"" + require("./images/desk.svg") + "\">\n        <script src=\"index.js\"></script>\n    </body>\n</html>";
export default __webpack_public_path__ + "c58ff9d72352b98461e9b50bc7a28553.svg";
exports = module.exports = require("../node_modules/css-loader/dist/runtime/api.js")(true);
// Module
exports.push([module.id, "body {\n    font-size: 1em;\n}", "",{"version":3,"sources":["index.css"],"names":[],"mappings":"AAAA;IACI,cAAc;AAClB","file":"index.css","sourcesContent":["body {\n    font-size: 1em;\n}"]}]);

export default __webpack_public_path__ + "01f1344ea069d644fc25b1b869447810.css";

Here is the full stack:

Module build failed (from ./node_modules/extract-loader/lib/extractLoader.js):
[snip]/src/images/desk.svg:1
export default __webpack_public_path__ + "c58ff9d72352b98461e9b50bc7a28553.svg";
^^^^^^

SyntaxError: Unexpected token export
    at [snip]/node_modules/extract-loader/lib/extractLoader.js:81:28
    at Generator.next (<anonymous>)
    at step ([snip]/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at [snip]/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (<anonymous>)
    at new F ([snip]/node_modules/core-js/library/modules/_export.js:36:28)
    at [snip]/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12
    at evalModule ([snip]/node_modules/extract-loader/lib/extractLoader.js:150:63)
    at [snip]/node_modules/extract-loader/lib/extractLoader.js:138:28
    at Generator.next (<anonymous>)
    at step ([snip]/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at [snip]/node_modules/babel-runtime/helpers/asyncToGenerator.js:28:13
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
 @ multi ./src/index.js ./src/index.html main[1]

Fix loaderUtils deprecation warning

See webpack/loader-utils#56

DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
    at parseQuery (/Users/garth/dev/web/habitat/node_modules/extract-loader/node_modules/loader-utils/index.js:78:3)
    at Object.extractLoader (/Users/garth/dev/web/habitat/node_modules/extract-loader/lib/extractLoader.js:46:45)
    at LOADER_EXECUTION (/Users/garth/dev/web/habitat/node_modules/loader-runner/lib/LoaderRunner.js:119:14)
    at runSyncOrAsync (/Users/garth/dev/web/habitat/node_modules/loader-runner/lib/LoaderRunner.js:120:4)
    at iterateNormalLoaders (/Users/garth/dev/web/habitat/node_modules/loader-runner/lib/LoaderRunner.js:229:2)
    at iterateNormalLoaders (/Users/garth/dev/web/habitat/node_modules/loader-runner/lib/LoaderRunner.js:218:10)
    at /Users/garth/dev/web/habitat/node_modules/loader-runner/lib/LoaderRunner.js:233:3
    at runSyncOrAsync (/Users/garth/dev/web/habitat/node_modules/loader-runner/lib/LoaderRunner.js:130:11)
    at iterateNormalLoaders (/Users/garth/dev/web/habitat/node_modules/loader-runner/lib/LoaderRunner.js:229:2)
    at Array.<anonymous> (/Users/garth/dev/web/habitat/node_modules/loader-runner/lib/LoaderRunner.js:202:4)

I believe the solution is to bump the loader-utils dependency and use the getOptions method here https://github.com/peerigon/extract-loader/blob/master/src/extractLoader.js#L30

working incorrect with [email protected]

config in webpack.js

module: {
    rules: [
      {
        test: /\.html$/,
        use: [
          "file-loader?name=[name].[ext]",
          "extract-loader",
          "html-loader"
        ]
      },
      {
        test: /\.(png|gif|jpg)$/,
        use: [
          {
            loader: "file-loader",
            options: {
              name: utils.assetsPath('img/[name].[ext]')
            }
          }
        ]
      }
    ]
  }

next code is I want to handle

<body>
  <img src="imgs/wechat.jpg">
  <img src="imgs/wechat.jpg">
  <img src="imgs/wechat.jpg">
  <img src="imgs/wechat.jpg">
  <img src="imgs/wechat.jpg">
</body>

when I use [email protected] ,the result is

<body>
  <img src=/static/img/wechat.jpg>
  <img src=undefined>
  <img src=undefined>
  <img src=undefined>
  <img src=undefined>
</body>

how reslove this problem ,should I use the previous version of html-loader?

Import error with ES6 js script embedded in html body

  • Operating System: Windows 10 Pro
  • Node Version: 13.12.0
  • NPM Version: 6.14.4
  • webpack Version: 4.42.1
  • extract-loader Version: 5.0.1

Expected Behavior

extract-loader should correctly process ES6 files and their links passed to it by html-loader.

Actual Behavior

Running npx webpack resp. npm run webpack returns this error:

ERROR in ./src/html/index.html
Module build failed (from ./node_modules/extract-loader/lib/extractLoader.js):
C:\ ... \website\src\index.js:1
(function (exports, require, module, __filename, __dirname) { import { gsap } from 'gsap';
                                                              ^^^^^^

SyntaxError: Cannot use import statement outside a module
...

Code

webpack.config.js and package.json

index.html:

<!DOCTYPE html>
<html lang="en">
<head>
    ...
</head>
<body id="#body">
    <script type="module" src="../index.js"></script>
</body>
</html>

index.js:

import { gsap } from 'gsap';
import fullpage from 'fullpage.js';
import $ from 'jquery';

var ...

How Do We Reproduce?

File structure:

 - src/
         - html/
                - index.html
         - index.js

 - dist/
 - webpack.config.js
 - package.json

Then run npm run webpack

Loader fails to run along LoaderOptionsPlugin() in webpack2

When I use extract-loader along LoaderOptionsPlugin() in webpack2 it constantly fails with the following error:

...
Module build failed: TypeError: Cannot read property 'publicPath' of undefined
    at Object.extractLoader (/Users/korya/dev/plntr/embedded_fw/recipes-planitar/survey/node_modules/extract-loader/lib/extractLoader.js:47:102)

Versions:

webpack: 2.2.0-rc.3
extract-loader: 0.1.0

Relevant parts of my config

  ...
  module: {
    rules: [
      {
        enforce: 'pre',
        test: /\.js$/,
        loader: 'eslint-loader',
      },
      ...
      {
        test: /\.html$/,
        loader: 'file-loader!extract-loader!html-loader',
      },
      ...
    ],
  },

  plugins: [
    new webpack.LoaderOptionsPlugin({
      options: {
        eslint: {
          configFile: '.eslintrc.yml',
          emitErrors: true,
          failOnError: true,
        },
      },
    }),
  ],
...

As soon as I remove (delete or comment out) the new webpack.LoaderOptionsPlugin({...}) lines, everything works as expected.

v5.2.0 breaks parts of code loaded with ref-loader

We use extract-loader to compose template files like this:

// index.js
import template from '!file-loader!extract-loader!ref-loader!./template.soy';

// template.soy 
@ref(!ref-loader!./Part1.soy)
@ref(!ref-loader!./Part2.soy)

// Part1.soy
{template .Part1}
    {foreach $key in keys($ij.pageItem.preferences)}
        {if matches($key, '^visible_.*$')}
		{/if}
    {/foreach}
{/template}

// Part2.soy
{template .Part2}
{/template}

After upgrade extract-loader to v5.2.0 whole code part after $ is not included in result file. Downgrade extract-loader to v5.0.1 only works fine.

e.g. produce

// template.soy
{template .BackbaseModel}
    {foreach $key in keys($ij.pageItem.preferences)}
        {if matches($key, '^visible_.*$

{template .Part2}
{/template}

I suppose it's regex-relative thing.
Probably somewhat connected with #57 and #54 ()

Extracting from deep modules hierarchy

#9

/**
 * Executes the given CommonJS module in a fake context to get the exported string. The given module is expected to
 * just return a string without requiring further modules.
 * ...
 */
function runModule(src, filename) {
// ...

The given module is expected to just return a string without requiring further modules.
So it works when there is no deep hierarchy. So for example when using the interpolate feature of html-loader then something like ${require('partials/header.html')} from inside index.html works but when there is another require inside partials/header.html or <img src="...">then it fails.

Could it be handled somehow recursively?

EDIT: I'm trying to solve it but I have a problem :P. I cannot shim the require as it is done in the loader since it's obviously synchronous in node but _loadModule is asynchronous in webpack (what a surprise! :-)). Any idea how to handle it?

@jhnns and others?

The only idea I have is to create a plugin which would extract it from the bundle itself :-/

Not working with html-loader interpolation

This loader configuration fails with TypeError: require(...) is not a function.

{
   test: /\.html$/,
   loader: 'file?name=[name].[ext]!extract!html?interpolate',
}
<div id="root">${require('./app')}</div>

However, if i remove extract loader - no errors.

Error can't resolve extract-loader

I have a project which works fine with extract-loader 3.1. Upgraded to extract-loader 4 today morning and now it won't compile. Webpack fails with the following error

ERROR in Entry module not found: Error: Can't resolve 'extract-loader' in 'C:\portfolio-app'

ERROR in multi (webpack)-dev-server/client?http://localhost:8080 ./src/app.scss
Module not found: Error: Can't resolve 'extract-loader' in 'C:\portfolio-app'
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./src/app.scss main[1]

Attaching a sample webpack config file which gives error on extract-loader 4 but works fine on 3.1.0
webpack.config.js.txt

sass compile with css: require is not defined

ref: webpack-contrib/sass-loader#584

ERROR in ./style.scss
    Module build failed (from ./node_modules/extract-loader/lib/extractLoader.js):
    NonErrorEmittedError: (Emitted value instead of an instance of Error) ReferenceError: require is not defined
        at runLoaders (/Users/willin/Desktop/sass-demo/node_modules/webpack/lib/NormalModule.js:300:13)
        at /Users/willin/Desktop/sass-demo/node_modules/loader-runner/lib/LoaderRunner.js:364:11
        at /Users/willin/Desktop/sass-demo/node_modules/loader-runner/lib/LoaderRunner.js:230:18
        at context.callback (/Users/willin/Desktop/sass-demo/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
        at process._tickCallback (internal/process/next_tick.js:68:7)
     @ multi (webpack)-dev-server/client?http://localhost:8081 ./style.scss

source: https://github.com/wshow/sass-demo

Since 3.0.0 version get "Error: Cannot find module" when using file paths with '~'

Hie!
This is my project https://github.com/g1un/path-resolve-issue
I added "src/fonts" to my resolve.modules in webpack.config.js (https://github.com/g1un/path-resolve-issue/blob/test/webpack.config.js#L33) and tried to use fonts with path with '~' (https://github.com/g1un/path-resolve-issue/blob/test/src/scss/components/_fonts.scss#L4).
It works with [email protected], but do not with [email protected], giving:

ERROR in ./src/scss/style.scss
Module build failed (from ./node_modules/extract-loader/lib/extractLoader.js):
/Users/ilyasmal/work/bogdanovka/node_modules/resolve/lib/sync.js:45
    throw err;
    ^

Error: Cannot find module 'roboto-light.woff2' from '/Users/ilyasmal/work/bogdanovka/src/scss'
    at Function.module.exports [as sync] (/Users/ilyasmal/work/bogdanovka/node_modules/resolve/lib/sync.js:43:15)
    at /Users/ilyasmal/work/bogdanovka/node_modules/extract-loader/lib/extractLoader.js:100:60
    at require (/Users/ilyasmal/work/bogdanovka/node_modules/extract-loader/lib/extractLoader.js:93:86)
    at /Users/ilyasmal/work/bogdanovka/src/scss/style.scss:7:8341
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at ContextifyScript.Script.runInNewContext (vm.js:65:15)
    at /Users/ilyasmal/work/bogdanovka/node_modules/extract-loader/lib/extractLoader.js:132:20
    at Generator.next (<anonymous>)
    at step (/Users/ilyasmal/work/bogdanovka/node_modules/babel-runtime/helpers/asyncToGenerator.js:17:30)
    at /Users/ilyasmal/work/bogdanovka/node_modules/babel-runtime/helpers/asyncToGenerator.js:35:14
    at new Promise (<anonymous>)
    at new F (/Users/ilyasmal/work/bogdanovka/node_modules/core-js/library/modules/_export.js:36:28)
    at /Users/ilyasmal/work/bogdanovka/node_modules/babel-runtime/helpers/asyncToGenerator.js:14:12
    at evalModule (/Users/ilyasmal/work/bogdanovka/node_modules/extract-loader/lib/extractLoader.js:150:63)
    at evalDependencyGraph (/Users/ilyasmal/work/bogdanovka/node_modules/extract-loader/lib/extractLoader.js:152:12)
    at Object.<anonymous> (/Users/ilyasmal/work/bogdanovka/node_modules/extract-loader/lib/extractLoader.js:32:31)
 @ ./src/js/app.js 3:0-30
 @ ./src/js/dev.app.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:8080 ./src/js/dev.app.js

Produced URL is "undefined" rather than expected URL.

I have a bug that surfaced after updating css-loader, but is apparently a bug in extract-loader.

The issue:

After upgrading to 2.0.0 from 1.0.1, I am getting url(undefined) in my output CSS where I previously got a valid URL.

This seems to happen when the URL is referenced multiple times across imported files - after the first reference undefined is output.

  • Operating System: Arch Linux
  • Node Version: 11.3.0
  • NPM Version: 6.4.1
  • webpack Version: 4.27.1

Expected Behavior

The URL should be the same each time it is referenced.

Actual Behavior

undefined is output instead of the URL after the first reference.

Code

@import "./test2";

.test1 {
    background: url(../../assets/test.png);
}
.test2 {
    background: url(../../assets/test.png) repeat;
}

Produces:

.test2{background:url(d41d8cd98f00b204e9800998ecf8427e.png) repeat}.test1{background:url(undefined)}

How Do We Reproduce?

See the attached project.

And the response from the css-loader project - I assumed it was a problem on their end as it surfaced with the updated version, but apparently not:

Sorry not related to css-loader, problem in extract-loader, problem here https://github.com/peerigon/extract-loader/blob/master/src/extractLoader.js#L144, need rewrite logic, maybe use Object/Map (like { __EXTRACT_LOADER_PLACEHOLDER__000_000: 'asset.png' }) and get asset url based __EXTRACT_LOADER_PLACEHOLDER__000_000 index.

SyntaxError: Unexpected identifier

I am loading an HTML file through the latest HTML loader(@1.0.0-alpha.0) and extract loader(@3.0.0):

{
    test: /\.html$/,
    use: [{
      loader: 'extract-loader',
    }, {
      loader: 'html-loader',
    }],
}

I created a plugin to peek at the result from the HTML loader, it is as follows:

import HTML__URL__0 from './logo.svg';


// HTML
export default `<!doctype html>
<html>
  <head>
    <title>Test</title>
    <link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css">
  </head>
  <body>
    <div id="root"></div>
    <img src="${HTML__URL__0}">
  </body>
</html>
`

When the extract loader tries to execute this code, the error message is as follows:

UnhandledPromiseRejectionWarning: evalmachine.<anonymous>:2
import HTML__URL__0 from './logo.svg';
       ^^^^^^^^^^^^

SyntaxError: Unexpected identifier

extract-loader 1.0.2 doesn't work with css-loader v0.28.8

Hi guys.

css-loader v0.28.8 implements url escaping: webpack-contrib/css-loader@8897d44

extract-loader 1.0.2 has attempt to fix incompatibility: ac3fccd#diff-453648f7ddcea53f5543562ba9bf0d3d

But it doesn't work in my case since css-loader injects relative url to css-base in my case:
This leads to invalid dependency resolve:

TypeError: require(...) is not a function
at D:\blablabla\node_modules\bootstrap\dist\css\bootstrap-theme.css:1:74
at ContextifyScript.Script.runInContext (vm.js:35:29)
at ContextifyScript.Script.runInNewContext (vm.js:41:15)
at Object.extractLoader (D:\blablabla\node_modules\extract-loader\lib\extractLoader.js:89:12)
@ ./node_modules/bootstrap/dist/css/bootstrap-theme.css 3:1-142
@ ./src/main/js/css.js

ERROR in ./node_modules/file-loader/dist/cjs.js!./node_modules/extract-loader/lib/extractLoader.js!./node_modules/css-loader!./node_modules/bootstrap/dist/css/bootstrap.css
Module build failed: D:\blablabla\node_modules\bootstrap\dist\css\bootstrap.css:2
exports = module.exports = require("../../../css-loader/lib/css-base.js")(false);(url)

So, looks like it is required to handle both absolute and relative urls. At least I changed testing url to wider
/^[^!]*[\/\\]css-loader[\/\\].*\.js$/i.
and now application builds w/o errors.

Not sure how it should be fixed in proper way: via wider regexp or via relative-to-absolute conversion. I think rel2abs is more strict.

require is not a function when using with html-loader

package.json

  "dependencies": {
    "css-loader": "^2.1.1",
    "extract-loader": "^3.1.0",
    "file-loader": "^3.0.1",
    "html-loader": "^0.5.5",
    "style-loader": "^0.23.1",
    "webpack-cli": "^3.3.0",
    "webpack": "^4.30.0"
  }

webpack.config.js

  entry: './index.html',
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: 'main.js',
  },
  module: {
    rules: [
      {
        test: /\.html$/,
        use: [ 'file-loader', 'extract-loader', {
            loader: 'html-loader',
            options: {attrs: [':data-href'],},},],
      },
      {
        test: /\.css/,
        use: [ 'style-loader', 'css-loader', ],

index.html

<div data-href="./test.css"></div>

output


WARNING in configuration
The 'mode' option has not been set, webpack will fallback to 'production' for this value. Set 'mode' option to 'development' or 'production' to enable defaults for ea
ch environment.
You can also set it to 'none' to disable any default behavior. Learn more: https://webpack.js.org/concepts/mode/

ERROR in ./index.html
Module build failed (from ./node_modules/extract-loader/lib/extractLoader.js):
NonErrorEmittedError: (Emitted value instead of an instance of Error) TypeError: require(...) is not a function
    at runLoaders (C:\Users\LJ\Desktop\extracthtml\node_modules\webpack\lib\NormalModule.js:298:13)
    at C:\Users\LJ\Desktop\extracthtml\node_modules\loader-runner\lib\LoaderRunner.js:367:11
    at C:\Users\LJ\Desktop\extracthtml\node_modules\loader-runner\lib\LoaderRunner.js:233:18
    at context.callback (C:\Users\LJ\Desktop\extracthtml\node_modules\loader-runner\lib\LoaderRunner.js:111:13)
    at Object.<anonymous> (C:\Users\LJ\Desktop\extracthtml\node_modules\extract-loader\lib\extractLoader.js:40:7)
    at Generator.throw (<anonymous>)
    at step (C:\Users\LJ\Desktop\extracthtml\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
    at C:\Users\LJ\Desktop\extracthtml\node_modules\babel-runtime\helpers\asyncToGenerator.js:30:13

it's will be ok

  • when i removed the attrs: [':data-href'], in the webpack.config.js

  • when i removed the data-href="./test.css" in the index.html

`@import` doesn't work well with symlinks

I created a reproduce demo here https://github.com/peerigon/extract-loader/pull/64/files

In this case the main.css imports common.css which is a symlink to symlinks/common.css.

      1 .
      2 โ”œโ”€โ”€ symlinks
      3 โ”‚ย ย  โ””โ”€โ”€ common.css -> ../common.css
      4 โ”œโ”€โ”€ common.css
      5 โ”œโ”€โ”€ hi.jpg
      6 โ”œโ”€โ”€ index.html
      7 โ”œโ”€โ”€ main.css
      8 โ””โ”€โ”€ main.js
      9
     10 1 directory, 6 files

The Webpack build failed because the basedir in resolve.sync was wrong.

basedir: path.dirname(filename),

image

Support extract jade ?

I'm using Jade, and can I compile my index.jade to index.html then extract it ?
Here's my trial but failed:
var indexHtml = __dirname + '/src/views/index.html';
{ test: indexHtml, loaders: [ "file?name=[name].[ext]", "extract", "html", "jade" ] }
Any Help? Many thanks ~

Glob multiple HTML files?

I'm wondering if it's possible to pass multiple HTML files through extract-loader, as it does exactly what I want. I'm hoping to glob an entire directory so that all my images can be hashed.

Thank you!

extract-loader and hot-reload

I've started using extract-loader in my project and noticed that webpack-dev-server stopped reload page after changes've been made to my html files. I worked when I used plain file-loader. I'm using the same config as you provided in example:

module: {
        loaders: [
            {
                test: /\.html$/,
                loaders: [
                    "file?name=[name].[ext]",
                    "extract",
                    "html?" + JSON.stringify({
                        attrs: ["img:src", "link:href"]
                    })
                ]
            }
}

Calculation of indexOfQuery incorrect

require: givenRelativePath => {
const indexOfQuery = Math.max(givenRelativePath.indexOf("?"), givenRelativePath.length);
const relativePathWithoutQuery = givenRelativePath.slice(0, indexOfQuery);

Shouldn't this be Math.min not Math.max? Otherwise we might as well write:

const indexOfQuery = givenRelativePath.length;

I've rolled back to 2.0.1 in order to use oneOf/resourceQuery in webpack config until this is fixed.

Support Webpack v4

I'm getting the following error:

ERROR in ./src/utils/404/404.extract.html
Module build failed: TypeError: Cannot read property 'output' of undefined
    at Object.extractLoader (./node_modules/extract-loader/src/extractLoader.js:31:72)
 @ ./src/utils/404/404.component.ts 18:15-44
 @ ./src/app/index.routing.ts
 @ ./src/app/index.module.ts
 @ ./src/main.ts

This points to the line https://github.com/peerigon/extract-loader/blob/master/src/extractLoader.js#L31, which seems this.options.output is no longer defined.

According to the v4 migration guide (here), this.options has been removed. Instead of loader-utils and checking this.options, you now get all options from this.query. Although, I'm not sure if that carries the publicPath option set by the webpack config. Also not sure what that publicPath's intended usage is here within the context of extract-loader. Setting it to null worked for me.

Extra dependencies when aliases are using

When extract-loader process result from css-loader, it creates dependencies inside sandboxed require:

var absPath = _path2.default.resolve(_path2.default.dirname(_this.resourcePath), resourcePath);
// Mark the file as dependency so webpack's watcher is working
_this.addDependency(absPath);

But if aliases (or other webpack features to redirect request) are used, resourcePath contains "raw" path, not final result. So if I use image with path 'i/some.png' inside CSS, and 'i' - alias to '/some-dir', extract-loader adds phantom dependency for non-existing file 'context-dir/i/some.png'. Those deps make watcher + require context behavior very strange: all modules inside 'context-dir' are invalidated after any changes in this dir!

@jhnns , could you plz add some check before adding dependency? Something like fs.existsSync, for example.

extract-loader and css-loader sourceMap is undefined

Issue

i use extract-loader and css-loader to generate source map, but the sourceURL always prepend aundefined

body{color:red}body a{color:#fff}body.open{background-color:#fef}

/*# sourceURL=undefined/src/index.scss */
...

Reason

I found that sourceRoot does not necessarily exist, sometimes it equals undefined.

I look for some codes, and found that https://github.com/peerigon/extract-loader/blob/master/src/extractLoader.js#L141, it uses extractExports function to transform, (Function toString()) sandbox.module.exports; And the css-loader (webpack-contrib/css-loader#674 (comment)) use cssWithMappingToString and the variables cssMapping.sourceRoot to concat string, but https://github.com/webpack-contrib/css-loader/blob/master/src/index.js#L76 has been remove the sourceRoot, so that extract-loader can not found sourceRoot anymore, and sourceRoot always to undefined

Suggest

I suggest extract-loader can compatibles it, when the sourceRoot is undefined

Environment

My package.jsonand webpack config below:

// package.json
{
    "extract-loader": "^3.1.0",
    "css-loader": "^3.4.0",
}
// webpack config
{
  loader: 'extract-loader'
},
{
  loader: 'css-loader',
  options: {
    sourceMap: true
  }
},
{
  loader: 'sass-loader',
  options: {
    sourceMap: true,
    sassOptions: {
      sourceMapRoot: '/'
    }
  }
}

undefined image src if image used twice in html

webpack.config.js

  mode: 'development',
  module: {
    rules: [
      {
        test: /\.html$/i,
        use: ['file-loader?name=[name].[ext]', 'extract-loader', 'html-loader'],
      },
      {
        test: /\.jpg$/,
        use: ['file-loader?name=[name].[ext]'],
      }
    ],
  },
};

src/index.js
import './index.html'

src/index.html

<img src="img.jpg">
<img src="img.jpg">

src/img.jpg
simple image

When I run webpack, it generates index.html file with this html:

<img src="img.jpg">
<img src="undefined">

The first img tag has correct src, but the second src is undefined.

I think problem with extract-loader. Thanks for help.

ModuleNotFoundError when using @import-s in CSS

I get the below error when using extract-loader after css-loader. It seems that it messes up relative paths and wants to find a module by one folder higher in the path hierarchy - but css-loader is working fine, if you comment out extract-loader in the Webpack config file you can see its output in the dist folder.

Please advise. Here's a tiny repro repo:
extractLoaderCssError.zip

Just install with NPM and then run webpack to see the error.

Am I doing something wrong or is this extract-loader's fault?

ERROR in ./main.css
Module build failed (from ./node_modules/extract-loader/lib/extractLoader.js):
ModuleNotFoundError: Module not found: Error: Can't resolve '../node_modules/css-loader/index.js' in '/home/user/csstest'
    at factory.create (/home/user/csstest/node_modules/webpack/lib/Compilation.js:798:10)
    at factory (/home/user/csstest/node_modules/webpack/lib/NormalModuleFactory.js:397:22)
    at resolver (/home/user/csstest/node_modules/webpack/lib/NormalModuleFactory.js:130:21)
    at asyncLib.parallel (/home/user/csstest/node_modules/webpack/lib/NormalModuleFactory.js:224:22)
    at /home/user/csstest/node_modules/neo-async/async.js:2817:7
    at /home/user/csstest/node_modules/neo-async/async.js:6783:13
    at /home/user/csstest/node_modules/neo-async/async.js:2817:7
    at done (/home/user/csstest/node_modules/neo-async/async.js:2914:13)
    at resolver.resolve (/home/user/csstest/node_modules/webpack/lib/NormalModuleFactory.js:447:23)
    at doResolve (/home/user/csstest/node_modules/enhanced-resolve/lib/Resolver.js:184:12)
    at hook.callAsync (/home/user/csstest/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/user/csstest/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at resolver.doResolve (/home/user/csstest/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:37:5)
    at hook.callAsync (/home/user/csstest/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/user/csstest/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at hook.callAsync (/home/user/csstest/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/user/csstest/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:12:1)
    at resolver.doResolve (/home/user/csstest/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:42:38)
    at hook.callAsync (/home/user/csstest/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn1 (eval at create (/home/user/csstest/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:24:1)
    at hook.callAsync (/home/user/csstest/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn1 (eval at create (/home/user/csstest/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:24:1)
    at hook.callAsync (/home/user/csstest/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn1 (eval at create (/home/user/csstest/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:24:1)
    at hook.callAsync (/home/user/csstest/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
    at _fn0 (eval at create (/home/user/csstest/node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:15:1)
    at fs.stat (/home/user/csstest/node_modules/enhanced-resolve/lib/DirectoryExistsPlugin.js:22:13)
    at process.nextTick (/home/user/csstest/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:73:15)
    at _combinedTickCallback (internal/process/next_tick.js:132:7)
    at process._tickCallback (internal/process/next_tick.js:181:9)

ERROR in ./main.css
Module not found: Error: Can't resolve '../node_modules/css-loader/index.js' in '/home/user/csstest'
resolve '../node_modules/css-loader/index.js' in '/home/user/csstest'
  using description file: /home/user/csstest/package.json (relative path: .)
    No description file found
    no extension
      /home/user/node_modules/css-loader/index.js doesn't exist
    .js
      /home/user/node_modules/css-loader/index.js.js doesn't exist
    .json
      /home/user/node_modules/css-loader/index.js.json doesn't exist
    as directory
      /home/user/node_modules/css-loader/index.js doesn't exist
[/home/user/node_modules/css-loader/index.js/package.json]
[/home/user/node_modules/css-loader/index.js]
[/home/user/node_modules/css-loader/index.js.js]
[/home/user/node_modules/css-loader/index.js.json]
 @ ./main.css -!../node_modules/css-loader/index.js??ref--4-2!../node_modules/resolve-url-loader/index.js??ref--4-3!/home/user/csstest/someFolder/anotherFolder/anotherCss.css

[help] issues with html-loader interpolation

Hi,

I'm in the works of developing my own static site generator that relies on pug templates, and markdown content.

I use webpack to bundle the precompiled pug (i.e. html) files, along with css+js, and also to process images etc.

I'm facing an issue using html-interpolation, such that the output bundle has undefined for image sources etc.

For reference, the compiled HTML looks as such:

...
    <script src="${require('../../base/templates/index.sss')}"></script>
...
            <span class="image-wrapper">
                <img class="image-preview" src=${require('../../content/pages/res/mini.jpg').preview} alt="test" title="sss">
                <img class="image-main" onload="this.classList.add('image-loaded')" src=${require('../../content/pages/res/mini.jpg').src} srcset=${require('../../content/pages/res/mini.jpg').srcSet} alt="test" title="sss">
            </span>
...

Webpack does include and process the required images, however the output HTML is as such:

...
    <script src="[object Object]"></script>
...
            <span class="image-wrapper">
                <img class="image-preview" src=undefined alt="test" title="sss">
                <img class="image-main" onload="this.classList.add('image-loaded')" src=undefined srcset=undefined alt="test" title="sss">
            </span>
...

The css interpolated require also appears to have issues, but this may be at my own fault.

The repo may be found here: https://github.com/zacharyrs/ssg.z

Hopefully someone can see where I'm going wrong, or if this is at fault of extract-loader.

Thanks,
Zach

Supporting js extraction?

I am new to webpack and might have a slippery grasp on how this all works exactly, but seeing as my index.html had a <script src="js/main.js"> tag in it, I figured it wouldn't be unreasonable for the loader to see this tag and extract the source into the build directory appropriately, but discovered that it was just evaluating the contents of it instead and outputting nothing, causing build errors. In the source it looks like this could be fixed by just changing the test for node evaluation to be /css-base\.js$/. Or is that not how this is meant to be used?

Doesn't work with aliases properly

When WebPack has aliases propery:

module.exports = {
...
resolve: {
    extensions: ['.js'],
    alias: {
      default: path.resolve(__dirname, 'default'),
      './default': path.resolve(__dirname, 'default'),
    }
  }
}

and extract-loader is being used with an html-loader

module.exports = {
...
module: {
    rules: [
      {
        test: /\.html$/,
        use: [
          {
            loader: 'extract-loader',
          },
          {
            loader: 'html-loader',
          }
        ]
      }
    ]
}
...
}

end temple that uses aliases default:

<img src="default/course-default.jpg" />
...
<img src="images/logo.svg" alt="">

extract-loader - gives me an error:

Error: Cannot find module './default/course-default.jpg' from '/webpack-demo/src'

But with the same configuration and old version "extract-loader": "^2.0.0" - everything is working just fine!
Is there something wrong happening with the extract-loader?

Rename file? (support request)

Is there a way to rename the output file? For instance, I have a simple SCSS file that I want extracted to [hash].css. Currently:

config.module.rules.push({
    test: /\.(scss)$/,
    use: ["extract-loader", "css-loader", "sass-loader"]
  });

And I'm getting a file named [hash].scss. Do I need to add another loader to change the filename output?

Missing Babel dependencies in 5.0

There are a few issues with #69 and the 5.0 release. The babel config uses relative preset/plugin names like "env", which causes babel to resolve it relative to the project's directory, not the directory where extract-loader is installed. If the user's project does not use Babel 6, or uses a different version, that is a problem.

The fix for that is to do require('babel-preset-env') in the babel config, so it resolves to the version of that package installed with extract-loader.

I tried to fix that but ran into a different issue. babel-preset-env is not listed as a dependency, but as a devDependency for extract-loader. That is an easy fix of course, but I'm not sure if it's the best thing to do to depend on babel-preset-env. If the goal is only to support ES modules, would it be a better idea to use babel-plugin-modules-commonjs?

TypeError: require(...) is not a function

Hi, I have this issue, I hope you can help me.
This problem is very curious since it was presented 2 days ago after deleting node_module and reinstalling the packages (I do not update any version packages or node), I describe:

App.jsx

import 'react-table/react-table.css'

webpack.config.js

module:{
    rules:[
      ...
      {
        test: /\.css$/,
        use: [
          'style-loader/url',
          'url-loader?limit=10000',
          'extract-loader',
          'css-loader?root=' + path.resolve(__dirname, 'assets')
        ]
      }
   ]
}

command

npm run dev-server

Result

10% building modules 1/1 modules 0 active
Project is running at http://0.0.0.0:8081/
  webpack output is served from /
Content not from webpack is served from ./build
404s will fallback to /index.html                                                
Hash: 50cfb73d68cbc86989c2
Version: webpack 3.10.0
Time: 27055ms
Asset       Size  Chunks                    Chunk Names
0.bundle.js    1.71 MB       0  [emitted]  [big]
1.bundle.js    1.51 MB       1  [emitted]  [big]
2.bundle.js     936 kB       2  [emitted]  [big]
bundle.js    3.95 MB       3  [emitted]  [big]  main
0.bundle.js.map    1.66 MB       0  [emitted]
1.bundle.js.map    1.56 MB       1  [emitted]
2.bundle.js.map    1.02 MB       2  [emitted]
bundle.js.map    4.51 MB       3  [emitted]         main
index.html  484 bytes          [emitted]
  [1] ./node_modules/react/index.js 190 bytes {3} [built]
  [276] ./node_modules/react-router-redux/es/index.js 420 bytes {3} [built]
  [277] ./node_modules/react-router-dom/es/index.js 925 bytes {3} [built]
  [282] ./theme/index.js 5.99 kB {3} [built]
  [297] ./node_modules/url/url.js 23.3 kB {3} [built]
  [366] ./node_modules/material-ui/styles/getMuiTheme.js 13.1 kB {3} [built]
  [510] multi (webpack)-dev-server/client?http://0.0.0.0:8081 babel-polyfill ./app.jsx 52 bytes {3} [built]
  [511] (webpack)-dev-server/client?http://0.0.0.0:8081 7.63 kB {3} [built]
    [531] ./node_modules/babel-polyfill/lib/index.js 833 bytes {3} [built]
  [733] ./app.jsx 8.7 kB {3} [built]
  [821] ./node_modules/material-ui/styles/MuiThemeProvider.js 2.14 kB {3} [built]
  [847] ./node_modules/react-x-ray/dist/XRay.js 2.08 kB {3} [built]
  [1268] ./node_modules/react-table/react-table.css 847 bytes {3} [built]
  [1271] ./modules/index.js 5.98 kB {3} [built]
  [1273] ./node_modules/url-loader!./assets/images/logo/blue.png 20.3 kB {3} [built]
+ 1662 hidden modules

ERROR in ./node_modules/url-loader?limit=10000!./node_modules/extract-loader/lib/extractLoader.js!./node_modules/css-loader?root=/Users/mymachine/Documents/myproject/assets!./node_modules/react-table/react-table.css
Module build failed: /Users/mymachine/Documents/myproject/node_modules/react-table/react-table.css:1
exports = module.exports = require("../css-loader/lib/css-base.js")(false);
                                                                   ^

TypeError: require(...) is not a function
at /Users/mymachine/Documents/myproject/node_modules/react-table/react-table.css:1:68
at Script.runInContext (vm.js:74:29)
at Script.runInNewContext (vm.js:80:15)
at Object.extractLoader (/Users/mymachine/Documents/myproject/node_modules/extract-loader/lib/extractLoader.js:88:12)
@ ./node_modules/react-table/react-table.css 3:1-184
@ ./app.jsx
@ multi (webpack)-dev-server/client?http://0.0.0.0:8081 babel-polyfill ./app.jsx
  Child html-webpack-plugin for "index.html":
1 asset
  [0] ./node_modules/html-webpack-plugin/lib/loader.js!./index.html 795 bytes {0} [built]
  [1] ./node_modules/lodash/lodash.js 540 kB {0} [built]
  [2] (webpack)/buildin/global.js 509 bytes {0} [built]
  [3] (webpack)/buildin/module.js 517 bytes {0} [built]
webpack: Failed to compile.

Thanks for your help

Reference cycles cause no output to be generated

I've provided an example in a git repository and a description in the README in that repo.

Quoting the readme:

This bug can be triggered by reference cycles.

Since each reference is just resolved to a filename rather than the target's contents (unless hashes are present in filenames), it should be possible for it to work properly.

The fairly common case of several web pages all referring to each other via a link-bar can trigger this (and is how I've come across it).

In src/index.pug, there is a reference to src/other/index.pug.

In src/other/index.pug, there is a reference to src/index.pug.

If delete the output dist folder then run webpack, I get no files emitted.

But if I comment out the reference back to the src/index.pug in src/other/index.pug, then the build works, generating both pages.

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.