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

Webpack in windows #58

Closed
codingluke opened this issue Jan 9, 2020 · 5 comments
Closed

Webpack in windows #58

codingluke opened this issue Jan 9, 2020 · 5 comments

Comments

@codingluke
Copy link

codingluke commented Jan 9, 2020

Dear all,

first of all, this is a very nice project! THX you all for your work!

I successfully added webpack to the build process with the following task

task webpack(type: NodeTask, dependsOn: 'npmInstall') {
	script = project.file('node_modules/.bin/webpack')
}

now we also have some windows programmers on board, for them the node_modules/.bin/webpack is not working, we have to take node_modules/.bin/webpack.cmd. However, the NodeTask is not able to use run a .cmd file.

We managed to get it working with

task webpack_windows(type: Exec, dependsOn: 'npmInstall') {
	commandLine 'cmd', '/c', project.file('node_modules/.bin/webpack.cmd')
}

however, as is is not a NodeTask node has to be locally installed. does anybody has an idea how to get it working on windows, without they have to install node globally too?

best Lukas

@bsautel
Copy link
Contributor

bsautel commented Jan 9, 2020

Hi @codingluke,

Using npx is probably the best and easiest solution to your issue. It is a tool provided with npm which enables to call commands bundled in npm packages such as webpack.

There is a NpxTask that enables you to use this tool as described in the documentation.

You need to write something like this:

task webpack(type: NpxTask, dependsOn: 'npmInstall') {
	command = 'webpack'
}

Hope this will help you!

@codingluke
Copy link
Author

Hi @bsautel

You are genius! It works like a charm locally and also on jenkins. Hopefully it will work for my windows colleges as well. We will see later.

Thanks for your help!

@codingluke
Copy link
Author

@bsautel just for your information. As I declare webpack in the package.json a NpmTask is sufficient, given that `npx' was not updated since two years, and windows user have some outstanding issues when their user name has white space. zkat/npx#146 (comment). open since 2 years! Also there is a real question mark whether this project is dead. npm/npx#30

task webpack(type: NpmTask, dependsOn: 'npmInstall') {
	args = ['run', 'webpack' ]
}

@bsautel
Copy link
Contributor

bsautel commented Jan 9, 2020

What you did also works, but requires to declare the command in the package.json file.

You are right, the npx package in the npmjs repository is old. But npx is distributed with npm with the same version as npm. For instance, on my computer:

npm --version
6.13.4
npx --version
6.13.4

No worry, it is actively maintained. See the npx announcement blog post and the npx command source code in the npm active github repository.

It sounds like the issue you are talking about is about an old version of npx, this repository is now read-only.

Note that the gradle-node-plugin has some integration tests for NpxTask that pass on Windows.

@codingluke
Copy link
Author

codingluke commented Jan 9, 2020

Propably you are right, when they deliver it with npm they should care about. The original repo is archived because it is moved to an official npm repo https://github.com/npm/npx. But there it is also not really active (and the windows issue is not fixed). Anyway, I am very glad the gradle-node-plugin is actively developed and it works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants