-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
93 lines (91 loc) · 2.54 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const WebpackDevServer = require('webpack-dev-server');
const webpack = require('webpack');
const pkg = require('./package.json');
const UglifyJsPlugin = webpack.optimize.UglifyJsPlugin;
const HtmlWebpackPlugin = require('html-webpack-plugin'); //installed via npm
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
// const ReloadPlugin = require('reload-html-webpack-plugin');
// const CleanWebpackPlugin = require('clean-webpack-plugin');
const env = require('yargs').argv.env;
let libraryName = 'skynet';
let outputFile;
let plugins = [];
if (env === 'build') {
plugins.push(new UglifyJsPlugin({ minimize: true }));
outputFile = libraryName + '.min.js';
} else {
outputFile = libraryName + '.js';
}
const PORT = 3000;
const config = {
entry:
{
'lib/numb' : __dirname + '/src/numb/numb.js',
'lib/operators': __dirname + '/src/numb/operators.js',
'lib/autograd': __dirname + '/src/numb/autograd/autograd.js'
},
devtool: 'source-map',
devServer: {
contentBase: __dirname + '/dist',
port: PORT,
hot: true,
inline: true
},
output: {
path: __dirname + '/dist/',
publicPath: '/dist/',
hotUpdateChunkFilename: 'hot/hot-update.js',
hotUpdateMainFilename: 'hot/hot-update.json',
// filename: outputFile,
filename: '[name].js',
library: libraryName,
libraryTarget: 'umd',
umdNamedDefine: true
},
module: {
rules: [
{
test: /(\.jsx|\.js)$/,
loader: 'babel-loader',
exclude: /(node_modules|bower_components)/
},
{
test: /(\.jsx|\.js)$/,
loader: 'eslint-loader',
exclude: /node_modules/
}
]
},
resolve: {
modules: [path.resolve('./node_modules'), path.resolve('./src')],
extensions: ['.json', '.js']
},
plugins: [
new webpack.NoEmitOnErrorsPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: './src/index.html',
// inject: true
}),
new HtmlWebpackPlugin({
filename: 'autograd.html',
template: './src/autograd.html',
// inject: false
}),
new HtmlWebpackPlugin({
filename: 'benchmark.html',
template: './src/benchmark.html',
// inject: true
}),
new HtmlWebpackPlugin({
filename: 'unittest.html',
template: './src/unittest.html',
// inject: true
}),
new CopyWebpackPlugin([{from: 'test/', to:'test/' }]),
new webpack.HotModuleReplacementPlugin()
]
};
console.log(Object.keys(pkg.dependencies));
module.exports = config;