Skip to content
This repository was archived by the owner on Feb 13, 2024. It is now read-only.

Commit be5531d

Browse files
committed
feat: import lodash
1 parent 62118e1 commit be5531d

File tree

8 files changed

+93
-16
lines changed

8 files changed

+93
-16
lines changed

.babelrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
}]
66
],
77
"plugins": [
8-
"syntax-dynamic-import"
9-
]
8+
"syntax-dynamic-import",
9+
"lodash"
10+
],
1011
}
1112

package-lock.json

Lines changed: 69 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,15 @@
3434
"devDependencies": {
3535
"babel-core": "^6.26.0",
3636
"babel-loader": "^7.1.2",
37+
"babel-plugin-lodash": "^3.3.2",
3738
"babel-plugin-syntax-dynamic-import": "^6.18.0",
3839
"babel-preset-env": "^1.6.1",
3940
"commitizen": "^2.9.6",
4041
"current-device": "^0.7.2",
4142
"cz-conventional-changelog": "^2.1.0",
4243
"html-loader": "^0.5.1",
44+
"lodash": "^4.17.4",
45+
"lodash-webpack-plugin": "^0.11.4",
4346
"path": "^0.12.7",
4447
"uglifyjs-webpack-plugin": "^1.1.5",
4548
"webpack": "^3.10.0",

src/cLive2DApp.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ let opacityDefault = 0.7;
4141
let opacityHover = 1;
4242

4343
export default () => {
44-
console.log(config);
4544
/*
4645
headPos = typeof iHeadPos === 'undefined' ? 0.5 : iHeadPos;
4746
opacityDefault = typeof iOpacityDefault === 'undefined' ? 0.7 : iOpacityDefault;

src/configValidater.js

Whitespace-only changes.

src/index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
'use strict';
1414

1515
import device from 'current-device';
16-
import { config, applyConfig }from './lib/configManager.js';
16+
import { config, configApplyer }from './lib/configManager.js';
1717

1818
/**
1919
* The public entry point
@@ -22,19 +22,21 @@ import { config, applyConfig }from './lib/configManager.js';
2222

2323
export function init(userConfig){
2424

25+
userConfig = typeof userConfig === 'undefined' ? {} : userConfig;
26+
2527
if (process.env.NODE_ENV === 'development') {
2628
console.log('Hey that, you are now in DEV MODE.');
2729
}
2830
try{
29-
applyConfig(userConfig);
31+
configApplyer(userConfig);
3032
}catch(err){
3133
console.error(err);
3234
}
33-
35+
/*
3436
if((!config.mobile.show)&&(device.mobile())){
3537
return;
3638
}
37-
39+
*/
3840
import(/* webpackMode: "lazy" */ './cLive2DApp').then(_ => {
3941
_.default();
4042
}).catch(err => {

src/lib/configManager.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @description The container of configeration.
55
*/
66

7+
import _ from 'lodash';
78

89
let currConfig = {};
910

@@ -46,15 +47,21 @@ const defaultOptions = {
4647
checked: true,
4748
}
4849

49-
function applyConfig(inUserConfig){
50+
function configApplyer(inUserConfig){
51+
console.log(_.defaults({ 'a'1 }, { 'a'3, 'b'2 }));
5052
if (!!!inUserConfig.checked) checkUserConfig(inUserConfig);
5153
// TBD.
5254
}
5355

5456
function checkUserConfig(inUserConfig){
5557
// TBD.
5658
}
59+
60+
function configDefaulter(){
61+
62+
}
63+
5764
export {
58-
applyConfig,
65+
configApplyer,
5966
currConfig as config,
6067
}

webpack.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const webpack = require('webpack');
2-
const path = require('path')
2+
const path = require('path');
3+
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
34
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
45
const visualizer = require('webpack-visualizer-plugin');
56
const manifestPlugin = require('webpack-manifest-plugin');
@@ -36,6 +37,7 @@ module.exports = env => {return{
3637
'NODE_ENV': JSON.stringify((isProd(env) ? 'production' : 'development')),
3738
}
3839
}),
40+
new LodashModuleReplacementPlugin(),
3941
new UglifyJsPlugin({
4042
cache: false,
4143
parallel: true,

0 commit comments

Comments
 (0)