I have the following webpack.mix.js setup for my Laravel Mix script:
let mix = require('laravel-mix');
let LiveReloadPlugin = require('webpack-livereload-plugin');
mix.webpackConfig({
plugins: [
new LiveReloadPlugin({
port: '35729',
})
],
});
if (mix.inProduction()) {
mix.disableNotifications();
}
mix
.options({
postCss: [
require('autoprefixer'),
],
processCssUrls: false,
})
.setPublicPath('./static')
.sass('./resources/sass/app.scss', 'css')
.sourceMaps(true, 'source-map')
.version();
mix
.options({
postCss: [
require('autoprefixer'),
],
processCssUrls: false,
})
.setPublicPath('./static')
.sass('./resources/sass/login.scss', 'css')
.sourceMaps(true, 'source-map')
.version();
When I run npm run development
I get the following output (including Sourcemaps)
DONE Compiled successfully in 5987ms 12:35:24
Asset Size Chunks Chunk Names
css/app.css 343 KiB mix [emitted] mix
css/app.css.map 400 KiB mix [emitted] [dev] mix
css/login.css 163 KiB mix [emitted] mix
css/login.css.map 236 KiB mix [emitted] [dev] mix
mix.js.map 3.73 KiB mix [emitted] [dev] mix
However, if I run npm run production
I get the following output (without Sourcemaps)
DONE Compiled successfully in 9029ms 12:33:57
Asset Size Chunks Chunk Names
css/app.css 278 KiB 0 [emitted] [big] mix
css/login.css 129 KiB 0 [emitted] mix
mix.js.map 4.52 KiB 0 [emitted] [dev] mix
I'm using Laravel Mix 5.0.1, and haven't been able to find a solution through other bug issues/SO questions -- they all seem to relate to sourcemaps not working on development and fixing it using devtools: 'inline-source-map'
which is not relevant here.
The only thing I could think of was the minification causing an issue, as the webpack docs suggest (https://webpack.js.org/configuration/devtool/#devtool):
If the default webpack minimizer has been overridden (such as to customise the terser-webpack-plugin options), make sure to configure its replacement with sourceMap: true to enable SourceMap support.
I couldn't find any documentation with Laravel Mix to support this though.
Any idea how I can fix this?
you should set false
to generateForProduction
parameter in mix.sourceMaps()
function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With