I have the following webpack config:
var path = require('path')
var webpack = require('webpack')
module.exports = {
entry: {
main: './scripts/app/main.js'
},
output: {
path: path.resolve(__dirname, './scripts/app/bundle/'),
publicPath: '/scripts/app/bundle/',
filename: '[name].js'
},
...
When i run the command npm run dev
it shows that main.js has been emitted
When I browse to /scripts/app/bundle/main.js
sure enough the file is loaded in the browser
But when i look inthe physical path there is no file - seems like its only in memory
This is what I have in package.json:
"scripts": {
"dev": "cross-env NODE_ENV=development webpack-dev-server --open --hot",
"build": "cross-env NODE_ENV=production webpack --progress --hide-modules"
},
How do I generate a physical file.
Output is a property that tells webpack where to emit / save the bundles it creates and how to name these bundled files. By default the main output file gets stored in ./dist/main. js and other generated files are stored in ./dist . module. exports = { output: { path: path.
Configuring the output configuration options tells webpack how to write the compiled files to disk. Note that, while there can be multiple entry points, only one output configuration is specified.
To answer your specific question, the webpack configuration is stored wherever your global node_modules are installed; on Windows this is typically %AppData%\Roaming\npm\node_modules\powerbi-visuals-tools\lib\webpack.
Webpack will generate the files and put them in the /dist folder for you, but it doesn't keep track of which files are actually in use by your project. In general it's good practice to clean the /dist folder before each build, so that only used files will be generated.
webpack-dev-server
does not generate files on disk -- only on memory. However you do have some options:
webpack --watch
, which will use webpack
to build your app and produce output to the disk. The downside is you won't have hot reloading. /webpack-dev-server
to the URL where you are running the server. So, if your server is running on localhost:3000
, you can view files by going to the URL http://localhost:3000/webpack-dev-server.
The files will still be served from memory, but you will be able to see them through this URL. webpack-dev-server
to write files to disk. If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With