Reputation: 452
How should I set up my webpack config to run webpack-dev-server from src
folder, not dist
? I mean not only change path because then babel is not working. Now I have a problem that everything is served from bundle.js and I can't see for example where is an error. Here's my config file :
const path = require('path');
module.exports = {
entry: './src/index.js',
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js',
publicPath: '/dist/'
},
module: {
rules: [
{
test: /\.js$/,
loader: 'babel-loader',
include: [
path.resolve(__dirname,'src')
]
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
}
]
},
devServer: {
compress: true,
port: 8000
}
}
Upvotes: 0
Views: 254
Reputation: 906
You can specify the devserver.contentBase
to define where the server will serve content from, but this shouldn't be necessary unless you're trying to serve static files. The default is the current working directory and will be served from memory rather than from the output.path
. Also, if you're not aware of it, your output.publicPath
is making the content be served at localhost:8000/dist/
References:
https://webpack.js.org/configuration/dev-server/#devserver-contentbase
http://webpack.github.io/docs/webpack-dev-server.html
Upvotes: 0