-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
94 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,4 +8,4 @@ module.exports = function (table, filename) { | |
saveAs(b, filename + '.png'); | ||
}); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,4 +32,4 @@ module.exports = function (table, charset, type) { | |
type: type, | ||
table: office | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,59 +1,45 @@ | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
var webpack = require('webpack'); | ||
var src = './src/index.js'; | ||
var md = ['json', 'txt', 'csv', 'xml', 'doc', 'xls', 'image', 'pdf']; | ||
var modules = (process.env['MODULES'] || '').split(' '); | ||
var notypes = []; | ||
var noimg = false; | ||
var nopdf = false; | ||
var content = null; | ||
if (modules[0]) { | ||
notypes = md.filter(function (m) { | ||
if (modules.indexOf(m) === -1) { | ||
if (m === 'image') { | ||
noimg = true; | ||
} else if (m === 'pdf') { | ||
nopdf = true; | ||
} | ||
return true; | ||
} else { | ||
return false; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const webpack = require('webpack'); | ||
/** | ||
* @desc 获取需要剔除的模块 | ||
*/ | ||
let blocks = []; | ||
let modules = ['json', 'txt', 'csv', 'xml', 'doc', 'xls', 'image', 'pdf']; | ||
if (process.env['MODULES']) { | ||
process.env['MODULES'].split(' ').forEach(m => { | ||
let index = modules.indexOf(m); | ||
if (index !== -1) { | ||
modules.splice(index, 1); | ||
} | ||
}); | ||
} | ||
if (notypes.length) { | ||
content = fs.readFileSync(src).toString(); | ||
notypes.forEach(function (m) { | ||
var r = new RegExp('/\\*' + m + '-wrap\\*/([\\s\\S]+?)/\\*' + m + '-wrap\\*/', 'g'); | ||
content = content.replace(r, ''); | ||
}); | ||
if (noimg && nopdf) { | ||
content = content.replace(/\/\*image-pdf-wrap\*\/([\s\S]+?)\/\*image-pdf-wrap\*\//g, ''); | ||
} else if (noimg || nopdf) { | ||
content = content.replace(/\/\*type-if-wrap\*\/([\s\S]+?)\/\*type-if-wrap\*\//g, 'type === \'' + (noimg ? 'pdf' : 'image') + '\''); | ||
} | ||
src = './src/index-tmp.js'; | ||
fs.writeFileSync(src, content); | ||
var callback = function () { | ||
fs.unlinkSync(src); | ||
}; | ||
process.on('SIGINT', callback); | ||
process.on('uncaughtException', callback); | ||
process.on('exit', callback); | ||
blocks = modules; | ||
} | ||
|
||
module.exports = { | ||
entry: src, | ||
entry: './src/index.js', | ||
output: { | ||
libraryTarget: 'umd', | ||
library: 'tableExport', | ||
path: path.join(__dirname, 'dist'), | ||
filename: 'tableExport.js' | ||
}, | ||
plugins: [ | ||
new webpack.optimize.UglifyJsPlugin({ | ||
sourceMap: false | ||
}) | ||
] | ||
module: { | ||
rules: [{ | ||
test: /\.js$/, | ||
enforce: 'pre', | ||
exclude: /(node_modules|bower_components|\.spec\.js)/, | ||
use: [{ | ||
loader: 'webpack-strip-block', | ||
options: { | ||
blocks: blocks | ||
} | ||
}] | ||
}], | ||
}, | ||
devServer: { | ||
contentBase: path.join(__dirname, 'demo'), | ||
compress: true, | ||
port: 3000 | ||
} | ||
}; |