Skip to content

Requiring .js from .html doesn't use defined loaders #124

@wilsonpage

Description

@wilsonpage

I'm submitting a bug report

Webpack version:
2.x

HTML-Loader version:
0.4.5

Please tell us about your environment:
OSX 10.x / Linux / Windows 10

OSX

Current behavior:

Webpack is not running defined loaders on modules imported into .html entrypoints.

Expected/desired behavior:

I expect the following module to be run through my defined babel-loader, but it's choking on ES6 syntax.

<script async src="${require('./index.js')}"></script>
  • If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem along with a gist/jsbin of your webpack configuration.
module.exports = {
  context: `${__dirname}/src`,
  entry: './index.html',

  output: {
    path: `${__dirname}/.dist`,
    filename: '[name].[hash].js',
  },

  module: {
    rules: [
      {
        test: /\.html$/,
        use: [
          'file-loader',
          'extract-loader',
          'html-loader?interpolate',
        ]
      },

      {
        test: /\.js$/,
        exclude: /(node_modules)/,
        use: [
          {
            loader: 'babel-loader',
            options: {
              presets: ['env'],
            },
          },
        ],
      },
    ]
  }
}
  • What is the expected behavior?

Imports within .html files should be treated as defined in the webpack config.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions