Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] When using MGT with SPFx 1.19, are the changes in the gulpfile.js still necesary? #3259

Closed
Rafaelki opened this issue Jul 19, 2024 · 6 comments

Comments

@Rafaelki
Copy link

Support Question

Hi,
My understanding is that the changes in the gulpfile.js are needed because SPFx was using an old version of Webpack. As SPFx 1.19 uses webpack 5, are these changes still needed?

If they are not needed or using webpack 5 has any impact on them, could you please update your sample in https://github.com/pnp/mgt-samples/tree/main/samples/app/sp-webpart to SPFx 1.19.

Related to: #3045

Thanks!

@musale
Copy link
Contributor

musale commented Jul 31, 2024

Pinging @gavinbarron to shed some light on this :)

@JonoSuave
Copy link

I'm running into the same issue

@JonoSuave
Copy link

@musale here's what my updated gulpfile looks like that seems to work:

"use strict";

const build = require("@microsoft/sp-build-web");
const path = require("path");

build.addSuppression(
	`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`
);

var getTasks = build.rig.getTasks;
build.rig.getTasks = function () {
	var result = getTasks.call(build.rig);

	result.set("serve", result.get("serve-deprecated"));

	return result;
};

// add babel-loader and some transforms to handle es2021 language features which are unsupported in webpack 4 by default
const litFolders = [
	`node_modules${path.sep}lit${path.sep}`,
	`node_modules${path.sep}@lit${path.sep}`,
	`node_modules${path.sep}lit-html${path.sep}`,
	`node_modules${path.sep}lit-element${path.sep}`,
];
build.configureWebpack.mergeConfig({
	additionalConfiguration: (generatedConfiguration) => {
		generatedConfiguration.module.rules.push({
			test: /\.js$/,
			// only run on lit packages in the root node_module folder
			include: (resourcePath) => litFolders.some((litFolder) => resourcePath.includes(litFolder)),
			use: {
				loader: "babel-loader",
				options: {
					plugins: [
						"@babel/plugin-transform-optional-chaining",
						"@babel/plugin-transform-nullish-coalescing-operator",
						"@babel/plugin-transform-logical-assignment-operators",
					],
				},
			},
		});
		return generatedConfiguration;
	},
});

build.initialize(require("gulp"));

@akshataggrwal
Copy link

We are getting the issue with MGT + SPFx 1.19 even after including lit-element in the gulp file.

@gavinbarron @musale

@musale
Copy link
Contributor

musale commented Oct 17, 2024

@akshataggrwal what's the output of the issue you're getting? I'm able to build with mgt and spfx 1.19. Please open an issue on pnp repo with all details, thanks.

@musale
Copy link
Contributor

musale commented Oct 17, 2024

@Rafaelki no.

I have created these issues on pnp side to address this:

Closing this question.

@musale musale closed this as completed Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done ✔️
Development

No branches or pull requests

4 participants