Answer the question
In order to leave comments, you need to log in
Webpack: how to set it up right?
Please help me set up the webpack config correctly. It needs to do livereload, jade->html, sass->css.
Now the config looks like this:
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: './src/index.js',
output: {
filename: 'main.js',
path: path.resolve(__dirname, 'dist'),
publicPath: '/',
sourceMapFilename: '[name].map'
},
devtool: "source-map",
devServer: {
hot: true, // Tell the dev-server we're using HMR
contentBase: path.resolve(__dirname, 'dist'),
publicPath: '/'
},
module: {
loaders: [
{
test: /\.css$/,
loader: "style-loader!css-loader"
}, {
test: /\.sass$/,
loaders: ['style-loader', 'css-loader', 'sass-loader']
}
]
}
};
Answer the question
In order to leave comments, you need to log in
There isn't too much info, but I'm going to hazard a guess that the problem is in `publicPath`. Please clarify
what exactly does "sass doesn't build" mean?
1) webpack-dev-server gives some error in the terminal and stops working?
2) works fine, but just doesn't silently build sass?
3) does it pull the old version of your sass files that were bundled before by the webpack team?
If the behavior fits #2 or #3, then most likely `webpack-dev-server` is building your code but doesn't know how to send it to the browser. It stores the folded code in RAM so old copies stay in the file system - that's why the browser always pulls in old files
Usually such problems arise if something is wrong with the output fields `publicPath` and `path`. Try to "play around" with them by adding, for example, `/assets`, and check in the browser what kind of static it is trying to request and at what URL.
If it doesn’t help, you can always run these two commands at the same time, it should work:
webpack --watch
webpack-dev-server
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question