Webpack does not generate build.js

I moved my codebase to a dockereform file.

I have a file for building dockers using the command: command: bash -c "rm -rf node_modules && npm install && npm run dev"

and everything works fine, I use rm -rf node_modules because it gives me some errors of missing packages (from my MAC). By doing this, it simply recreates, and it works fine on the local host.

I also added volumes, so when I change something in my code, it is reflected in my container, this also works fine (except for a hot restart, but this is not very important).

Now I usually just comment out the line: command: bash -c "rm -rf node_modules && npm install && npm run dev" in my docker file and instead add: command: bash -c "rm -rf node_modules && npm install && npm run build" to build my package, so in production I donโ€™t have a node at all, but it gives me no results.

Iโ€™m not sure if this is a problem with volumes, that is, it is created in the container, but I canโ€™t access it from my machine (which I donโ€™t think because changing the code on my local machine is really reflected in my container), or for some reason it is not created at all.

This is the result of command: bash -c "rm -rf node_modules && npm install && npm run build --verbose"

 NODE | npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules/fsevents): NODE | npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3 : wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}) NODE | NODE | added 115 packages in 11.036s NODE | npm info it worked if it ends with ok NODE | npm verb cli [ '/usr/local/bin/node', NODE | npm verb cli '/usr/local/bin/npm', NODE | npm verb cli 'run', NODE | npm verb cli 'build', NODE | npm verb cli '--verbose' ] NODE | npm info using npm@5.5.1 NODE | npm info using node@v9.2.0 NODE | npm verb run-script [ 'prebuild', 'build', 'postbuild' ] NODE | npm info lifecycle frontend@1.0.0 ~prebuild: frontend@1.0.0 NODE | npm info lifecycle frontend@1.0.0 ~build: frontend@1.0.0 NODE | NODE | > frontend@1.0.0 build /code/client NODE | > cross-env NODE_ENV=production webpack --progress --hide-modules NODE | NODE | Hash: cda5e46c2c7f4ba2903b NODE | Version: webpack 3.9.1 NODE | Time: 27298ms NODE | Asset Size Chunks Chunk Names NODE | build.js 1.29 MB 0 [emitted] [big] main NODE | build.js.map 7.65 MB 0 [emitted] main NODE | npm verb lifecycle frontend@1.0.0 ~build: unsafe-perm in lifecycle true NODE | npm verb lifecycle frontend@1.0.0 ~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/code/client/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin NODE | npm verb lifecycle frontend@1.0.0 ~build: CWD: /code/client NODE | npm info lifecycle frontend@1.0.0 ~postbuild: frontend@1.0.0 NODE | npm verb exit [ 0, true ] NODE | npm info ok 

And my webpack conf file starts as follows:

 var path = require('path') var webpack = require('webpack') module.exports = { entry: './src/main.js', output: { path: path.resolve(__dirname, '../static/dist/'), publicPath: '/dist/', filename: 'build.js' }, 

Which, at least before I worked perfectly, as my application looks like this:

 - manage.py - static - dist - others - client - webpack.config.js 

etc.

Why does nothing work in dist?

Update

I used exec to view the container. I can not find build.js anywhere. I also run touch abc.txt inside / code / static / dist, and it is also being created on my local host, that is, the volumes are working fine. This should be a web pack problem, not a docker.

Update 2

I also tried the full path, like this one, still nothing:

 module.exports = { entry: './src/main.js', output: { path: path.resolve(__dirname, '/code/static/dist'), publicPath: '/dist/', filename: 'build.js' }, 

Edit 3

I tried to find build.js. I found these files, but I think these are not my build.js:

 root@0xxxxxx :/code# find . -name build.js ./client/node_modules/node-forge/nodejs/build.js ./client/node_modules/errno/build.js ./client/node_modules/vue-template-compiler/build.js ./client/node_modules/builtin-status-codes/build.js ./client/node_modules/webpack-dev-middleware/node_modules/mime/src/build.js ./client/node_modules/node-gyp/lib/build.js ./client/node_modules/node-sass/scripts/build.js ./client/node_modules/mime/build/build.js ./client/node_modules/npm/node_modules/node-gyp/lib/build.js ./client/node_modules/npm/node_modules/sorted-union-stream/node_modules/from2/node_modules/readable-stream/node_modules/isarray/build/build.js ./client/node_modules/npm/lib/install/action/build.js ./client/node_modules/npm/lib/build.js 
+5
source share
4 answers

Your path is wrong. You create your build.js file from the project directory.

Just change to this:

path: path.resolve(__dirname, 'static/dist')

+3
source

I managed to solve it. I tried hundreds of things, so I'm not entirely sure that this did the trick, but creating a new file and publishing my dock computer on it made it work. I think this is possibly related to file permissions. Check them out if you get this error.

+3
source

You are missing a var path declaration. But webpack should lament without it, so I'm not sure what the reason is.

 var path = require('path'); 
+2
source

Try removing /dist/ from the path. He works on my car.

 module.exports = { entry: './src/main.js', output: { path: path.resolve(__dirname, '../static'), publicPath: '/dist/', filename: 'build.js' }, 
+2
source

Source: https://habr.com/ru/post/1273854/


All Articles