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

Commit

Permalink
feat: import lodash
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazeyu committed Jan 5, 2018
1 parent 62118e1 commit be5531d
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 16 deletions.
5 changes: 3 additions & 2 deletions .babelrc
Expand Up @@ -5,7 +5,8 @@
}]
],
"plugins": [
"syntax-dynamic-import"
]
"syntax-dynamic-import",
"lodash"
],
}

75 changes: 69 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Expand Up @@ -34,12 +34,15 @@
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-plugin-lodash": "^3.3.2",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-preset-env": "^1.6.1",
"commitizen": "^2.9.6",
"current-device": "^0.7.2",
"cz-conventional-changelog": "^2.1.0",
"html-loader": "^0.5.1",
"lodash": "^4.17.4",
"lodash-webpack-plugin": "^0.11.4",
"path": "^0.12.7",
"uglifyjs-webpack-plugin": "^1.1.5",
"webpack": "^3.10.0",
Expand Down
1 change: 0 additions & 1 deletion src/cLive2DApp.js
Expand Up @@ -41,7 +41,6 @@ let opacityDefault = 0.7;
let opacityHover = 1;

export default () => {
console.log(config);
/*
headPos = typeof iHeadPos === 'undefined' ? 0.5 : iHeadPos;
opacityDefault = typeof iOpacityDefault === 'undefined' ? 0.7 : iOpacityDefault;
Expand Down
Empty file added src/configValidater.js
Empty file.
10 changes: 6 additions & 4 deletions src/index.js
Expand Up @@ -13,7 +13,7 @@
'use strict';

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

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

export function init(userConfig){

userConfig = typeof userConfig === 'undefined' ? {} : userConfig;

if (process.env.NODE_ENV === 'development') {
console.log('Hey that, you are now in DEV MODE.');
}
try{
applyConfig(userConfig);
configApplyer(userConfig);
}catch(err){
console.error(err);
}

/*
if((!config.mobile.show)&&(device.mobile())){
return;
}

*/
import(/* webpackMode: "lazy" */ './cLive2DApp').then(_ => {
_.default();
}).catch(err => {
Expand Down
11 changes: 9 additions & 2 deletions src/lib/configManager.js
Expand Up @@ -4,6 +4,7 @@
* @description The container of configeration.
*/

import _ from 'lodash';

let currConfig = {};

Expand Down Expand Up @@ -46,15 +47,21 @@ const defaultOptions = {
checked: true,
}

function applyConfig(inUserConfig){
function configApplyer(inUserConfig){
console.log(_.defaults({ 'a'1 }, { 'a'3, 'b'2 }));
if (!!!inUserConfig.checked) checkUserConfig(inUserConfig);
// TBD.
}

function checkUserConfig(inUserConfig){
// TBD.
}

function configDefaulter(){

}

export {
applyConfig,
configApplyer,
currConfig as config,
}
4 changes: 3 additions & 1 deletion webpack.config.js
@@ -1,5 +1,6 @@
const webpack = require('webpack');
const path = require('path')
const path = require('path');
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const UglifyJsPlugin = require('uglifyjs-webpack-plugin');
const visualizer = require('webpack-visualizer-plugin');
const manifestPlugin = require('webpack-manifest-plugin');
Expand Down Expand Up @@ -36,6 +37,7 @@ module.exports = env => {return{
'NODE_ENV': JSON.stringify((isProd(env) ? 'production' : 'development')),
}
}),
new LodashModuleReplacementPlugin(),
new UglifyJsPlugin({
cache: false,
parallel: true,
Expand Down

0 comments on commit be5531d

Please sign in to comment.