I
I
Igor Prokofiev2020-08-09 13:39:22
npm
Igor Prokofiev, 2020-08-09 13:39:22

How to force Webpack to compile a module along with a project?

Hello.
I continue to fight with the assembly of a large project (js + vue + css), I collect it with Webpack.

The project has the main part (js, vue, scss) and there is a separate core module, which contains vue and scss files that draw the non-changeable parts of the front.

I installed this core module (npm i -D), but when I run npm run build, I don't get the built files from this module in the right directory. That is, suppose the module has head.js (+.scss) and footer.js, then after the project is built, they do not appear in the build directory, where the finished files are added.

How to make them appear there? The assembly passes without any errors, the module is specified in the dependencies. The feeling that the module simply does not cling to the project.

Configs:
package.js fragment of the project:

spoiler
{
"name": "@myproject/project",
"version": "2.1.0",
"private": true,
"scripts": {
"build": "cross-env NODE_ENV=myproject-production webpack --config webpack.prod.js",
},
"dependencies": {
"@mymodule/common": "0.0.1",
"atpl": "^0.9.3",
"body-scroll-lock": "^2.6.1",
...


Package.json lists only the dependencies of the module itself, there is no build script.
The webpack config of the project itself is very large, but if necessary, I can lay it out.

Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
WapSter, 2020-08-09
@wapster92

Well, you save it in devDependencies. Packages from there are not included in the final assembly. Move the package to dependencies and it should work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question