Failing to compile
Hello Bart,
Something is crushing the loader when I run npm run production command. The error doesn't provide much of the information as you can see below.
Error
94% after seal
ERROR Failed to compile with 0 errors 16:30:40
2 assets
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ production: `cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=webpack.config.js`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the @ production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The strange thing is that if I remove the following lines from the webpack.mix.js file
mix.webpackConfig({
module: {
rules: [{
test: /\.blade\.php$/,
use: [{
loader: 'webpack-blade-native-loader',
options: {
viewDir: 'resources/views'
}
}],
}],
},
});
it runs as expected and compiles the .HTML copy of the blade file but the blade syntax is still present in the new .HTML file. Obviously, this is expected as there is no blade loader set up in the webpack.
I also tried to setup the loader directly inside the webpack.config.js file like below but it produces the same results.
module.exports.module.rules.push({
test: /\.blade\.php$/,
use: [{
loader: 'webpack-blade-native-loader',
options: {
viewDir: 'resources/views'
}
}],
});
Since there is evidence that the following block of code inside the webpack.config.js is not crushing (at least when above is commented out)...
const HtmlWebpackPlugin = require('html-webpack-plugin');
const glob = require('glob');
const pages = glob.sync('home.blade.php', {
cwd: path.join(process.cwd(), `resources/views/`),
root: '/',
})
.map((page) => new HtmlWebpackPlugin({
filename: page.replace('.blade.php', '.html'),
template: `resources/views/${page}`,
}));
module.exports.plugins.push(...pages);
...I suspect that the problem might be with the Webpack Blade Native Loader itself
I'm running on Laravel 7.28.3 npm 6.14.6 html-webpack-plugin 4.5.0