package: add webpack, webpack.config.js and loaders

This commit is contained in:
Micooz 2017-08-07 22:12:33 +08:00
parent 2105b5649f
commit f27e44675e
5 changed files with 1089 additions and 23 deletions

4
.gitignore vendored

@ -19,5 +19,7 @@ coverage/
# others
blinksocks*.json
blinksocks*.js
blinksocks.client.js
blinksocks.server.js
blinksocks*.log
/build/blinksocks.js.map

@ -2,5 +2,5 @@ if (process.env.NODE_ENV === 'development') {
require('babel-register');
module.exports = require('../src');
} else {
module.exports = require('../lib');
module.exports = require('../build');
}

@ -5,7 +5,7 @@
"main": "lib/index.js",
"files": [
"bin",
"lib",
"build",
"AUTHORS"
],
"bin": {
@ -19,6 +19,7 @@
"test:coverage": "jest --coverage",
"lint": "eslint bin src",
"compile": "cross-env NODE_ENV=production babel src --out-dir build --minified --ignore __tests__,__mocks__",
"pack": "cross-env NODE_ENV=production webpack --config webpack.config.js",
"debug:client": "cross-env NODE_ENV=development node --inspect --inspect-port=9229 bin/cli-client.js --config blinksocks.client.js",
"debug:server": "cross-env NODE_ENV=development node --inspect --inspect-port=9230 bin/cli-server.js --config blinksocks.server.js",
"client": "node bin/cli-client.js --config blinksocks.client.js",
@ -36,17 +37,21 @@
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-jest": "^20.0.3",
"babel-loader": "^7.1.1",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-register": "^6.24.1",
"babili-webpack-plugin": "^0.1.2",
"cross-env": "^5.0.4",
"eslint": "^4.3.0",
"eslint-config-babel": "^7.0.1",
"eslint-loader": "^1.9.0",
"eslint-plugin-babel": "^4.1.2",
"eslint-plugin-flowtype": "^2.35.0",
"husky": "^0.14.3",
"jest": "^20.0.4"
"jest": "^20.0.4",
"webpack": "^3.4.1"
},
"repository": {
"url": "https://github.com/blinksocks/blinksocks",

65
webpack.config.js Normal file

@ -0,0 +1,65 @@
const path = require('path');
const webpack = require('webpack');
const BabiliPlugin = require('babili-webpack-plugin');
module.exports = {
bail: true,
devtool: 'source-map',
target: 'node',
entry: {
'blinksocks': './src/index.js'
},
output: {
path: path.resolve(__dirname, 'build'),
filename: '[name].js',
libraryTarget: 'commonjs2'
},
resolve: {
extensions: ['.js'],
modules: ['node_modules']
},
module: {
rules: [
{
test: /\.js$/,
enforce: 'pre',
loader: require.resolve('eslint-loader'),
include: [
path.resolve(__dirname, 'bin'),
path.resolve(__dirname, 'src')
]
},
{
test: /\.js$/,
loader: require.resolve('babel-loader'),
exclude: [
/node_modules/,
/__mocks__/,
/__tests__/
]
}
]
},
performance: {
hints: false
},
plugins: [
new BabiliPlugin(),
new webpack.BannerPlugin({
banner: 'Copyright (c) 2016-present, [name]. All rights reserved.\n\nname: [file]\nhash: [hash]',
entryOnly: true
})
]
};

1032
yarn.lock

File diff suppressed because it is too large Load Diff