Wednesday, May 29, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  29] [ 7]  / answers: 1 / hits: 15621  / 8 Years ago, fri, may 6, 2016, 12:00:00

When I build my js bundle with webpack using webpack-dev-server my code runs twice every time. Not sure how to fix it.



Screenshot of Developer Tools console



My webpack config:



var path = require('path');
var webpack = require('webpack');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
devtool: 'cheap-eval-sourcemap',
entry: [
'webpack-dev-server/client?http://localhost:8080',
'webpack/hot/dev-server',
path.join(__dirname, '../src/main')
],
output: {
path: path.join(__dirname, '../dist'),
filename: 'bundle.js'
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new HtmlWebpackPlugin({
template: path.join(__dirname, '../src/index.html')
}),
new CopyWebpackPlugin([
{
from: path.join(__dirname, '../assets'),
to: path.join(__dirname, '../dist/assets')
}
])
],
devServer: {
contentBase: path.join(__dirname, '../dist'),
outputPath: '/lol',
hot: true
},
module: {
loaders: [
{
test: /.js$/,
loaders: ['babel-loader'],
include: path.join(__dirname, '../src')
}
]
}
};

More From » webpack

 Answers
24

in the template file you might have manually added a loading the bundle.



If you don't have the



inject: false 


option in



new HtmlWebpackPlugin({
template: path.join(__dirname, '../src/index.html')
}),


the bundle will get added again.


[#62274] Thursday, May 5, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dylan

Total Points: 734
Total Questions: 91
Total Answers: 102

Location: Philippines
Member since Sat, Jul 11, 2020
4 Years ago
dylan questions
Thu, Feb 10, 22, 00:00, 2 Years ago
Wed, Nov 24, 21, 00:00, 3 Years ago
Fri, Apr 3, 20, 00:00, 4 Years ago
Mon, Mar 9, 20, 00:00, 4 Years ago
;