Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERROR in Error: Child compilation failed: Module build failed: Error: The path for file doesn't contain relativeTo param #73

Open
karthikdeva opened this issue Sep 22, 2017 · 6 comments

Comments

@karthikdeva
Copy link

I'm new into webpack and trying move gulp to webpack. facing issue in "ngtemplate-loader". Below is my webpack config.

const path = require('path');
const webpack = require("webpack");
const optimize = webpack.optimize;
const htmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const config = require('./webpack/config');

var webpackConfig = {

entry: {
    vendor: vendorResources,
    app: ["./src/app/index.module.ts"]     
},
output: {
    path: path.resolve(__dirname, "dist"),
    filename: "scripts/[name].js",
},
devtool: "source-map",
module: {
    rules: [{
            test: /\.html$/,
            use: [
                { loader: 'ngtemplate-loader?relativeTo=' + (path.resolve(__dirname, './src/app')) },
                { loader: 'html-loader' }
            ]
        },
        {
            test: /\.ts?$/,
            use: [{
                loader: 'awesome-typescript-loader'
            }, {
                loader: 'tslint-loader'
            }],
            exclude: /node_modules/
        }
    ],
},
resolve: {
    extensions: [".ts", ".tsx", ".js", ".json", ".jsx", ".css", ".scss", ".sass"]
},
externals: {},
plugins: [
    new ExtractTextPlugin({
        filename: (getPath) => {
            return getPath('styles/[name].css').replace('js', 'css');
        },
        allChunks: false
    }),
   
]

}
module.exports = webpackConfig;

@Vitenok
Copy link

Vitenok commented Feb 22, 2018

Hi @karthikdeva , have you solved this issue?

@nickbreaton
Copy link

Not sure if this is the original issue, but for me my test for /\.html/ was also picking my index.html file from my html-webpack-plugin. Putting an exclude: /index.html/ did it for me. You may have to adjust the exclude if you have other files names index.html, but the basic gist is:

module.exports = {
  ...
  module: {
    rules: [
      {
        exclude: /index\.html/,
        test: /\.html$/,
        use: [
          {
            loader: 'ngtemplate-loader',
            options: {
              relativeTo: './src'
            }
          },
          { loader: 'html-loader' }
        ]
      }
    ]
  },
  ...
}

@evankleist
Copy link

This seems to be a problem with the combination of this loader and HtmlWebpackPlugin. The index file used by HtmlWebpackPlugin throws errors unless it is excluded, as @nickbreaton pointed out. However, excluding index.html means that any references in that file will not be required.

@moonformeli
Copy link

@nickbreaton It worked for me, thanks!

@dikaso
Copy link

dikaso commented Aug 31, 2020

Is this maybe only windows problem?

@DostalTomas
Copy link

No, I have linux and experiencing same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants