Everything works perfect locally. I enabled source-maps in my webpack config and .map file is created.
Problem is when I push app to Heroku. If I inspect element I see that source maps are not enabled. I minimize my code so nothing is where it's supposed to be without source-maps.
How do I deploy to Heroku with source-maps?
EDIT:
webpack config
devtool: 'source-map',
module: {
rules: [
{
test: /\.(js|jsx)$/,
loader: 'babel-loader',
exclude: /node_modules|dist|build/,
options: {
babelrc: true,
},
},
{
test: /\.local\.(css|scss)$/,
use: ExtractLocal.extract({
fallback: 'style-loader?sourceMap',
use: [
{
loader: 'css-loader',
options: {
sourceMap: true,
minimize: true,
modules: true,
importLoaders: 1,
localIdentName: '[local]___[name]__[hash:base64:5]',
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-loader',
options: {
sourceMap: true,
},
},
{
loader: 'sass-resources-loader',
options: {
resources: [ path.resolve(__dirname, './src/client/styling/styles/variables.scss'), ],
},
},
],
}),
},
],
},
plugins: [
// new BundleAnalyzerPlugin(),
new webpack.optimize.UglifyJsPlugin({
sourceMap: true,
}),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
}),
]
package.json
"build-client": "cross-env NODE_ENV=production webpack --config webpack.config.prod.js",
"start": "cross-env NODE_ENV=production node ./src/build/bundle.js",
If I refresh my app on heroku and run heroku logs I get the below errors regarding source maps. H12 Request timeout. So Sourcemaps are there but are not being fetched by Heroku.
SOLUTION Ok, I found the problem. It was Nginx and not Heroku. I am using it between my Heroku app and server. The configuration was set up like this.
location ~* \.(js|css|gif|png|jpg|ico|svg|eot|ttf|otf|woff|woff2|json|xml)$ {
root "/app/src/dist/";
add_header Pragma public;
add_header Cache-Control public;
expires 1y;
gzip_static on;
gzip off;
log_not_found off;
access_log off;
}
As you can see there is no map extension so it was not fetching it. After I added it, everything started working properly.