Closed Ofer-Gal closed 3 months ago
I am guilty of not reading "Webpack extensibility" but even trying to use the example in samples/advanced/fast-serve/webpack.extend.js it did not work.
I don't understand webpack that much.
Just try to put below code in your webpack.extend.js:
/*
* User webpack settings file. You can add your own settings here.
* Changes from this file will be merged into the base webpack configuration file.
* This file will not be overwritten by the subsequent spfx-fast-serve calls.
*/
// you can add your project related webpack configuration here, it will be merged using webpack-merge module
// i.e. plugins: [new webpack.Plugin()]
const webpackConfig = {
module: {
rules: [{
test: /\.js$/,
include: [
/lit/,
/@lit/,
/lit-html/
],
use: {
loader: 'babel-loader',
options: {
plugins: [
'@babel/plugin-transform-optional-chaining',
'@babel/plugin-transform-nullish-coalescing-operator',
'@babel/plugin-transform-logical-assignment-operators'
]
}
}
}]
}
}
// for even more fine-grained control, you can apply custom webpack settings using below function
const transformConfig = function (initialWebpackConfig, webpack) {
// transform the initial webpack config here, i.e.
// initialWebpackConfig.plugins.push(new webpack.Plugin()); etc.
return initialWebpackConfig;
}
module.exports = {
webpackConfig,
transformConfig
}
That worked fine. Thanks!
I assume you mean \node_modules\spfx-fast-serve-helpers\lib\templates\webpack.extend.js
thank you