I have set up a small demo app for a library we are working on at my company. We are using Vue CLI with webpack and node. I have managed to deploy it to Heroku just fine using their git deployment setup.
Recently I found the need for a translations file to be generated after build. I use a node command and triggers a small script that compiles an array of all the properties needed to render the app. The file is stored in a folder called /dist. Then I have set up an alias to the root of the application to be able to find the properties file once we are in the webpack handled files.
My vue.config.js looks like this:
const path = require('path');
const ROOT = path.resolve(__dirname, '.');
module.exports = {
configureWebpack: {
resolve: {
alias: {
'@root': ROOT,
'@dist': path.resolve(ROOT, '/dist')
}
},
devServer: { ... }
}
};
And in my ./src/translationLoader.js I have the following lines to import the generated file:
import translations from '@dist/properties/translations-require.js';
// ...
AJS.I18n.keys = translations.en_UK;
It all works perfectly fine locally, but when I deploy to Heroku I get the following error message:
remote: > vue-cli-service build ./src/main
remote:
remote:
remote: - Building for production...
remote: ERROR Failed to compile with 1 errors7:09:01 AM
remote:
remote: This dependency was not found:
remote:
remote: * @dist/properties/translations-require.js in ./src/translation-loader.js
remote:
remote: To install it, you can run: npm install --save @/../dist/properties/translations-require.js
remote: ERROR Build failed with errors.
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! @refinedwiki/core-ui-docs@1.0.75 build: `vue-cli-service build ./src/main`
remote: npm ERR! Exit status 1
I have verified that the file is correctly generated by logging in to Heroku using their bash tool to find it in the file structure. Any ideas of what I could have left out?
For reference, here's the package.json for the project:
{
"name": "ui-docs",
"engines": {
"node": "14.15.x",
"npm": "6.14.x"
},
"scripts": {
"serve": "node i18nParser.js && vue-cli-service serve ./src/main --port 8100",
"build": "vue-cli-service build ./src/main",
"heroku-postbuild": "scripts/build-heroku.sh",
"pipelines-setup": "scripts/setup-pipelines.sh",
"pipelines-build": "scripts/build-pipelines.sh",
"pipelines-merge-master": "node_modules/.bin/merge-master",
"pipelines-config": "node_modules/.bin/config-setup",
"start": "node server.js",
"deploy": "node_modules/.bin/deploy-core",
"deploy-heroku": "scripts/deploy-heroku.sh"
},
"repository": "bitbucket:refinedwikiteam/core-ui-docs",
"license": "UNLICENSED",
"dependencies": {
"connect-history-api-fallback": "^1.6.0",
"express": "^4.16.4",
"fs-extra": "^9.0.1",
"properties-reader": "^2.1.1",
"serve-favicon": "^2.5.0",
"serve-static": "^1.13.2",
"vue": "^2.6.12",
"vue-router": "^3.4.3",
"webpack": "~4.41.6"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.4.0",
"@vue/cli-service": "^3.4.0",
"eslint-plugin-vue": "~6.0.1",
"node-sass": "^4.14.1",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.5.21"
}
}