xyz-data / UglifyJS-3

UglifyJS 3: JavaScript parser / mangler / compressor / beautifier toolkit
https://uglifyjs.xgqfrms.xyz
Other
1 stars 0 forks source link

UglifyJS 3 & CLI #3

Open xyzdata opened 6 years ago

xyzdata commented 6 years ago

UglifyJS 3 & CLI

https://github.com/gildata/UglifyJS-3/blob/UglifyJS3/README.md#command-line-usage

https://github.com/gildata/UglifyJS-3/blob/UglifyJS3/README.md#api-reference

xyzdata commented 6 years ago

ES5

`uglifyjs ./libs/modal.js -o ./build/modal.min.js -c -m reserved=['BouncedModal']

` image

ES6

`uglifyes ./libs/modal.js -o ./build/modal.min.js -c -m reserved=['BouncedModal']

https://github.com/gildata/UglifyJS-3/issues/1

xyzdata commented 6 years ago

Modal

$ npm i -g uglify-es

# uglifyjs ./libs/BouncedModal.js -o ./build/foo.min.js -c -m reserved=['BouncedModal']

# OK
$ uglifyjs -h
$ uglifyjs ./libs/modal.js -o ./build/modal.min.js -c -m reserved=['BouncedModal']

# ??? BAD
$ uglifyes -h
$ uglifyes ./libs/modal.js -o ./build/modal.min.js -c -m reserved=['BouncedModal']
xyzdata commented 6 years ago

https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/185

xyzdata commented 6 years ago

OK & bug ???

question

image


/*

// OK ???
uglifyjs -h

# BAD ???
uglifyjs ./libs/sidebar.js -o ./build/sidebar.min.js -c --mangle-props reserved=["STOCK_IP", "STOCK_Paths", "STOCK_SecCode"]

# OK
uglifyjs ./libs/sidebar.js -o ./build/sidebar.min.js -c --mangle-props reserved=["STOCK_IP"]

uglifyjs ./libs/sidebar.js -o ./build/sidebar.min.js -c --mangle-props keep_quoted

properties: {
    // mangle property options
    reserved: ["STOCK_IP", "STOCK_Paths", "STOCK_SecCode"]
},

*/
xyzdata commented 6 years ago

https://tutsplus.com/

xyzdata commented 6 years ago

    // init
    STOCK_SecCode = STOCK_F9_FV.Utils.getParam(`gilcode`);
    // STOCK_IP = `http://${window.parent.location.host}`;
    // STOCK_SecCode = `000001.SZ`;
    STOCK_IP = `http://10.1.5.202`;
    STOCK_Paths = `/webservice/fastview/stock`;
    console.log(`STOCK_SecCode `, STOCK_SecCode, typeof STOCK_SecCode);

gilcode=600570.SH & gilcode=000001.SZ

http://10.1.5.202/stock/f9/fastview/sidebar.html?gilcode=000001.SZ&market=4609&sid=hs#模块选择

http://10.1.5.202/stock/f9/fastview/sidebar.html?gilcode=600570.SH&market=4609&sid=hs#模块选择

iframe

pass .SZ/.SH

http://localhost:3000/?gilcode=000003&market=4609&sid=hs

http://localhost:3000/?gilcode=600570&market=4609&sid=hs

xyzdata commented 6 years ago

dataset

webpack uglify bug!

image

image

xyzdata commented 6 years ago

dataset name & webpack & uglify

https://github.com/webpack-contrib/uglifyjs-webpack-plugin

https://github.com/mishoo/UglifyJS2/issues/2561

https://github.com/webpack-contrib/uglifyjs-webpack-plugin/issues/185

xyzdata commented 6 years ago

Modal


$ npm i -g uglify-es

#OK 
uglifyjs -h
uglifyjs ./libs/modal.js -o ./build/modal.min.js -c -m reserved=['BouncedModal']
xgqfrms-GitHub commented 6 years ago

$ uglifyjs ./libs/modal.js -o ./libs/modal.min.js -c --mangle reserved=['BouncedModal']
$ uglifyjs ./libs/modal.js -o ./libs/modal.min.js -c -m reserved=[`BouncedModal`]
$ uglifyjs ./libs/modal.js -o ./libs/modal.min.js -c -m reserved=["BouncedModal"]
xgqfrms-GitHub commented 6 years ago

/*

$ npm i -g uglify-es

// OK ???
uglifyjs -h
uglifyjs ./libs/modal.js -o ./build/modal.min.js -c -m reserved=['BouncedModal']

*/
xyzdata commented 6 years ago

image

forced global variable

image


window.OTC_IP = ``;
window.OTC_PATH = ``;
window.OTC_GILCODE = ``;
// forced global variable

// webpack ignore ??? bug
window.onload = () => {
    initTabs();
    initSidebar();
    OTC_IP = `${window.parent.location.origin}`;
    OTC_PATH = `/webservice/fastview/otcper`;
    OTC_GILCODE = OTC_F9_FV.Utils.getParam(`gilcode`) ? OTC_F9_FV.Utils.getParam(`gilcode`) : `430002.OC`;
    // OTC_SOCKET = ``;
    console.log(`OTC_GILCODE `, OTC_GILCODE, typeof OTC_GILCODE);
    // window.OTC_GILCODE = OTC_GILCODE;
    // OTC_GILCODE = OTC_F9_FV.Utils.getParam(`gilcode`);
    // OTC_IP = `${window.parent.location.protocol}//${window.parent.location.host}`;
    // OTC_IP = `http://${window.parent.location.origin}`;
    // OTC_Paths = `/webservice/fastview/otcper`;
};