Skip to content

Commit

Permalink
⚡ 代码重构
Browse files Browse the repository at this point in the history
  • Loading branch information
Jogiter committed Sep 18, 2018
1 parent e51cbd1 commit 3bdaec4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 20 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,14 @@ module.exports = {
```js
module.exports = {
entry: './js/index.js',
template: 'index.html',
template: './index.html',
publicPath: '/',
hashDigestLength: 6,
__cacheDir: './__thunder/',
__destination: './assets/',
__ftp: {
'host': 'host',
'port': 'port',
'user': 'user',
'username': 'username',
'password': 'password',
'path': 'remotepath'
}
Expand Down Expand Up @@ -114,6 +113,7 @@ module.exports = {
+ [ ] `.browserslistrc` 配置
+ [ ] `.eslintrc` 配置
+ [ ] 添加测试
+ [ ] css minify


## 阅读链接
Expand Down
9 changes: 4 additions & 5 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ if (!Object.keys(cli.flags).length) {
}

const result = explorer.searchSync();
if (!result) {
console.log('thunder config file is not found, please check!');
process.exit(0);
}

bundle(result.config, cli);
let config = result ? result.config : {}
let isProduction = Boolean(cli.flags.build)

bundle(config, isProduction);
8 changes: 0 additions & 8 deletions demo/.thunderrc.js

This file was deleted.

11 changes: 7 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ function initWebpackConfig(option, isProduction) {

function setConfig(config) {
const DEFAULT = {
entry: 'js/index.js',
template: 'index.html',
entry: './js/index.js',
template: './index.html',
hashDigestLength: 6,
publicPath: '/',
__cacheDir: './__thunder/',
Expand All @@ -199,12 +199,15 @@ function setConfig(config) {
return config;
}

module.exports = function bundle(config, cli) {
module.exports = function bundle(config, isProduction) {
config = setConfig(config);
let isProduction = Boolean(cli.flags.build);
let webpackConfig = initWebpackConfig(config, isProduction);

function handler(err, stats) {
if (err) {
console.log(err);
process.exit()
}
if (!stats.hasErrors() && !stats.hasWarnings()) {
console.log(
stats.toString({
Expand Down

0 comments on commit 3bdaec4

Please sign in to comment.