Skip to content

frustrated with the global variable like $!!! #5139

@guzuomuse

Description

@guzuomuse

fist of all ,thanks for your effort to the great tool

and then there is an question frustrating me for a long time;
here it is :
global variable for this cli-tool;
for example:
if we want to use $ variable as in global way, the suggestion way of our cli
is editing the "script:[]" in the file ".angular-cli.json";
in this senario:
we can get a script.bundel.js when server running;
but the the '$' is limtted in the script.bundel.js,not be shared,it's a 'fake global';
that's say if we use other libary based on jquery '$' not included in the 'script:[]',the '$'
can't be accessed!we have to do some work like ' import * as $ from jquery'
but in this way,we will get an error like '$ is not defined';

so,we have to leave the 'script:[]' empty.and then verything is go well,but the $ is not global;
that's to say:either we include all the libary in the 'script:[...]' or left it empty;
they can never coexist;
to say the least,even ,we can included all the libary files in the 'script:[]'
the script.bundel.js file may very large size ,that's not good idea;

IMHO,I know we create this cli too not for expert,just for out of the box using;
so maybe we don't encurage to do more complex job on config webpack. i really
agree with this!

In sum,we just want to find a way to set 'real global' variable like config setting
in webpack.config.js:

plugins:[new webpack.ProvidePlugin({
		  jQuery: 'jquery',
		  $: 'jquery',
		  jquery: 'jquery'
		}) ];

so,how we go through this question?

thank you again.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions