Repository navigation
Closed
Description
Version
3.0.0-rc.3
Reproduction link
https://gist.github.com/pendenaor/591d5ffb3af4edbe640d20abeb8d999d
Steps to reproduce
- create an app with vue-cli 3 rc3
- copy App.vue and vue.config.js
- Run the app
What is expected?
jQuery and lodash are available
What is actually happening?
jQuery and lodash are 'undefined'
inspect command output
...
plugins: [
/* config.plugin('vue-loader') */
new VueLoaderPlugin(),
/* config.plugin('define') */
new DefinePlugin(
{
'process.env': {
NODE_ENV: '"development"',
VUE_APP_CLI_UI_URL: '""',
BASE_URL: '"/"'
}
}
),
/* config.plugin('case-sensitive-paths') */
new CaseSensitivePathsPlugin(),
/* config.plugin('friendly-errors') */
new FriendlyErrorsWebpackPlugin(
{
additionalTransformers: [
function () { /* omitted long function */ }
],
additionalFormatters: [
function () { /* omitted long function */ }
]
}
),
/* config.plugin('hmr') */
new HotModuleReplacementPlugin(),
/* config.plugin('no-emit-on-errors') */
new NoEmitOnErrorsPlugin(),
/* config.plugin('progress') */
new ProgressPlugin(),
/* config.plugin('html') */
new HtmlWebpackPlugin(
{
templateParameters: function () { /* omitted long function */ },
template: 'C:\\Public\\Repo\\new-vue-cli\\sinoc_ui\\public\\index.html'
}
),
/* config.plugin('preload') */
new PreloadPlugin(
{
rel: 'preload',
include: 'initial',
fileBlacklist: [
/\.map$/,
/hot-update\.js$/
]
}
),
/* config.plugin('prefetch') */
new PreloadPlugin(
{
rel: 'prefetch',
include: 'asyncChunks'
}
),
/* config.plugin('copy') */
new CopyWebpackPlugin(
[
{
from: 'C:\\Public\\Repo\\new-vue-cli\\sinoc_ui\\public',
to: 'C:\\Public\\Repo\\new-vue-cli\\sinoc_ui\\dist',
ignore: [
'index.html',
'.DS_Store'
]
}
]
),
{
definitions: {
$: 'jquery',
jquery: 'jquery',
'window.jQuery': 'jquery',
jQuery: 'jquery',
_: 'lodash'
}
}
],
...
Metadata
Metadata
Assignees
Labels
No labels
Activity
pendenaor commentedon Jun 21, 2018
found a way:
pedroresende commentedon Jun 25, 2018
@pendenaor I have a question, about this. Were you obliged to have
import $ from "jquery";in the<script>inside every vue file you wanted to use ? Did you add anything else to.eslintrc.js?pendenaor commentedon Jun 26, 2018
I import jquery in my
main.js. I didn't have.eslintrc.js, but in mypackage.json, i add these lines :pedroresende commentedon Jun 26, 2018
@pendenaor Thanks, however I can't make it to work ... I've added in main.js the import jquery (https://github.com/pedroresende/vue-experience/blob/master/src/main.js#L6) and I'm trying to use it in the Home.vue (https://github.com/pedroresende/vue-experience/blob/master/src/views/Home.vue#L18)
pedroresende commentedon Jun 26, 2018
@pendenaor Thanks, finally found the problem. It seems that I have to define jquery globally
francoismassart commentedon Feb 1, 2019
This topic was useful!
I was trying to inject the semver version string from my
package.jsonduring the build process of my Vue app.Here is how I injected this info via
vue.config.jsThen inside my sources in Vue:
process.env.PACKAGE_VERSION🥇AndreiSoroka commentedon Sep 22, 2019
@francoismassart
file
vue.config.js:from: #1904 (comment)
ortonomy commentedon Jan 7, 2021
@AndreiSoroka -- perfect, exactly what I was looking for.
vegerot commentedon Mar 18, 2021
@francoismassart @AndreiSoroka
This is very helpful. I was wondering how I can do something similar, but with an
asyncfunction.I want to get the git commit for diagnostic messages and
Vuex.version. The way I was thinking of doing it would be something likeor
Then have something like
or
So, how can I get that to work with something async? Just setting it to be
asyncdoesn't seem to work.Any other way to get git command output into buildtime?
fangbinwei commentedon Mar 19, 2021
@vegerot workaround #3328 (comment)
vegerot commentedon Mar 19, 2021
I actually made my own workaround. I just used
execSyncinsteadKeavon commentedon Dec 16, 2021
In case anyone's running across this like I did: the
VUE_APP_prefix is required (at least in Vue 3).And if your
.vuefile's JS doesn't know what the variableprocessis, you may need to add"node"to"compilerOptions": { "types": ["node"] }in yourtsconfig.json.