При открытии страницы index.html в браузере в консоле выводится:
Uncaught ReferenceError: webpackJsonp_name_ is not defined at babelPolyfill.js:2
babelPolyfill.js - полифилл от babel.
webpack.config.js:
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require("extract-text-webpack-plugin");
module.exports = {
//devtool: 'cheap-module-eval-source-map',
context: path.join(__dirname, 'frontend'),
entry: {
babelPolyfill: "babel-polyfill",
index: "./index",
common: "./common",
},
output: {
path: path.join(__dirname, 'public'),
filename: '[name].js',
publicPath: '/public/',
library: '[name]'
},
resolve: {
modules: [path.resolve(__dirname, "node_modules")]
},
resolveLoader: {
modules: ["web_loaders", "web_modules", "node_loaders", "node_modules"],
},
module: {
rules: [
{
exclude: /\/node_modules/,
loader: "babel-loader",
options: {
presets: [['es2015', {modules: false}], "es2016", "es2017", "react"],
plugins: ['transform-runtime'],
},
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract(
{
fallback: "style-loader",
use: ["css-loader","autoprefixer-loader?browsers=last 2 versions"]
}),
},
{
test: /\.less$/,
use: ExtractTextPlugin.extract(
{
fallback: "style-loader",
use: ["css-loader","autoprefixer-loader?browsers=last 2 versions","less-loader"],
}),
},
{
test: /\.(png|jpg|svg|ttf|eot|woff|woff2)$/,
use: "file?name=[name][hash].[ext]",
}
]
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new webpack.optimize.CommonsChunkPlugin({
name: "commons",
filename: "commons.js",
minChunks: 2,
}),
],
watch: true,
}
index.html:
<html>
<head>
<title>Title</title>
</head>
<body>
<script src="./public/babelPolyfill.js"></script>
<script src="./public/commons.js"></script>
<script src="./public/index.js"></script>
</body>
</html>