I am trying to get vue.js source code for production.
I used this command npm run build
. I got a dist
folder with index.html
and a folder named static
with all css
and js
.
When I tried running the index.html
in localhost, ie, xampp server I got a blank page .
Is it possible with vue.js to run in xampp.
Deploying the Vue sample app Navigate to the root folder of the application in the command line. Type npm install --global surge to install Surge on your computer. Type npm run build to build the application and make it production-ready. Type cd dist to navigate to the build folder.
Prerequisites. Install Node. js on Windows: This includes a version manager, package manager, and Visual Studio Code. The Node Package Manager (npm) is used to install Vue.
vue-cli-service build produces a production-ready bundle in the dist/ directory, with minification for JS/CSS/HTML and auto vendor chunk splitting for better caching. The chunk manifest is inlined into the HTML.
I had the same issue, and I solved the problem by deleting the "/" from the dist/index.html file. I had something like this:
<script src=/js/app.632f4e30.js></script>
And I change it to:
<script src=js/app.632f4e30.js></script>
First create vue.config.js file in project root directory and define base url in it using below code
module.exports = {
baseUrl: process.env.NODE_ENV === 'production'
? '/production-sub-path/'
: '/'
}
If you use Vue CLI 3.3 or higher, use
module.exports = {
publicPath: process.env.NODE_ENV === 'production' ?
'/production-sub-path/' :
'/'
}
Replace production-sub-path with your folder name ... eg. http://www.example.com/production-sub-path/ ... and run below command to build the project
npm run build
After finishing the build ... Copy/Upload all files in dist folder to your /production-sub-path/ folder... That's it
For more info checkout the official documentation https://cli.vuejs.org/guide/deployment.html#general-guidelines
I had this issue before as well. I solved it by making a change to the index.js file in the config folder. Under build, I changed:
assetsPublicPath: '/',
to
assetsPublicPath: '',
and tried npm run build again. I checked the dist file and opened the index.html and it worked, no blank page.
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