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 Template execution failed: ReferenceError: __webpack_require__ is not defined #676

Closed
CheezItMan opened this issue May 15, 2017 · 3 comments

Comments

@CheezItMan
Copy link

I'm having a bit of trouble deploying my webpack 2 app to Heroku. It seems like my app, using Underscore Templates in with my HTML is having trouble.

When I deploy to Heroku I get: ERROR in Template execution failed: ReferenceError: __webpack_require__ is not defined

My Repo is here: https://github.com/CheezItMan/tasklist-js

My webpack.config.js is:

var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var webpack = require('webpack');
var HTMLWebpackPlugin = require('html-webpack-plugin');
const DEVELOPMENT = process.env.NODE_ENV === 'development';

const PRODUCTION = process.env.NODE_ENV === 'production';

var entry = PRODUCTION ? './src/app.js'  :
              ['./src/app.js',
                'webpack/hot/dev-server',
                'webpack-dev-server/client?https://localhost:8080'
              ];

var plugins = PRODUCTION ? [
                  new webpack.LoaderOptionsPlugin({ minimize: false, debug: false }),
                  new ExtractTextPlugin('style-[contenthash:10].css'),
                  new HTMLWebpackPlugin({
                    template: 'index.html'
                  })
              ]
              : [
                new webpack.HotModuleReplacementPlugin(),
                new ExtractTextPlugin('styles.scss')
              ];
plugins.push(
              new webpack.DefinePlugin({
            		DEVELOPMENT: JSON.stringify(DEVELOPMENT),
            		PRODUCTION: JSON.stringify(PRODUCTION)
            	})
);
plugins.push (
              new webpack.ProvidePlugin({
                "$": 'jquery',
                "jQuery": 'jquery',
                'window.jQuery': 'jquery'
              })
);


const cssIdentifier = PRODUCTION ? '[hash:base64:10]' : '[path][name]---[local]';

const cssLoader = PRODUCTION	?	ExtractTextPlugin.extract({
			loader: 'css-loader?minimize&localIdentName=' + cssIdentifier
		})
	: 	['style-loader', 'css-loader?localIdentName=' + cssIdentifier];


module.exports = {
  devtool: 'source-map',
  entry: entry,
  plugins: plugins,
  output: {
		path: path.join(__dirname, 'dist'),
		publicPath: PRODUCTION ? '/' : '/dist/',
		filename: PRODUCTION ? 'bundle.[hash:12].min.js' : 'bundle.js'
	},
  module: {
    loaders: [{
      test: /\.js$/,
      loaders: ['babel-loader'],
      exclude: /node_modules/
    },
    {
      test: /\.(png|jpg|gif)$/,
      loaders: ['url-loader?limit=10000&name=images/[hash:12].[ext]'],
      exclude: '/node_modules/'

    },
    {
			test: /\.(css|scss)$/,
			loaders: cssLoader,
			exclude: /node_modules/
		},
    {
      test: /\.html$/,
      loader: "underscore-template-loader",
      exclude: /node_modules/,
      query: {
        engine: 'lodash',
      }
    }
  ]}
};
@mastilver
Copy link
Collaborator

I can see you removed: underscore-template-loader, did that solve your issue?

One thing you can do is be more specific with your test regex so you don't include index.html

@mastilver
Copy link
Collaborator

Closing this down, as it looks like you resolved your issue

@lock
Copy link

lock bot commented May 31, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 31, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants