2015-11-20 14:20:06 +01:00
|
|
|
var path = require('path')
|
|
|
|
var webpack = require('webpack')
|
|
|
|
var HtmlWebpackPlugin = require('html-webpack-plugin')
|
|
|
|
|
|
|
|
// Most of the config was copied from js-ipfs-api's webpack configuration
|
|
|
|
|
2015-12-12 11:54:14 +01:00
|
|
|
var config = {
|
|
|
|
entry: path.join(__dirname,'webapp','app.jsx'),
|
2015-11-20 14:20:06 +01:00
|
|
|
output: {
|
|
|
|
path: path.join(__dirname,'webapp','dist'),
|
|
|
|
filename: 'app.js'
|
|
|
|
},
|
|
|
|
resolve: {
|
|
|
|
modulesDirectories: [
|
2015-11-21 16:29:54 +01:00
|
|
|
'node_modules', './webapp/', 'lib', './webapp/components/', './webapp/assets/',
|
2015-11-28 09:01:38 +01:00
|
|
|
'./webapp/pages/', 'node_modules/font-awesome/css', 'node_modules/font-awesome/fonts'
|
2015-11-20 14:20:06 +01:00
|
|
|
],
|
|
|
|
alias: {
|
|
|
|
http: 'stream-http',
|
|
|
|
https: 'https-browserify'
|
|
|
|
}
|
|
|
|
},
|
2015-12-14 00:06:12 +01:00
|
|
|
eslint: {
|
|
|
|
configFile: './.eslintrc',
|
|
|
|
failOnWarning: true,
|
|
|
|
failOnError: true
|
|
|
|
},
|
2015-11-20 14:20:06 +01:00
|
|
|
module: {
|
2015-12-14 00:06:12 +01:00
|
|
|
preLoaders: [
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
|
|
|
loader: 'eslint-loader',
|
|
|
|
exclude: /node_modules/
|
|
|
|
}
|
|
|
|
],
|
2015-11-20 14:20:06 +01:00
|
|
|
loaders: [
|
|
|
|
{ test: /\.(ttf|eot|svg|woff(2?))(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' },
|
|
|
|
{ test: /\.css$/, loaders: ['style','css'] },
|
2015-11-21 16:29:54 +01:00
|
|
|
{ test: /\.md$/, loaders: ['html','markdown'] },
|
2015-11-20 14:20:06 +01:00
|
|
|
{ test: /\.json$/, loader: 'json' },
|
|
|
|
{
|
|
|
|
test: /\.jsx?$/,
|
2015-11-21 13:05:31 +01:00
|
|
|
exclude: /(node_modules|bower_components)/,
|
2015-11-20 14:20:06 +01:00
|
|
|
loader: 'babel',
|
|
|
|
query: {
|
|
|
|
presets: ['es2015','react'],
|
2015-12-13 13:30:54 +01:00
|
|
|
plugins: addTransformRuntime([])
|
2015-11-20 14:20:06 +01:00
|
|
|
}
|
2015-11-21 14:35:08 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
test: /\.js$/,
|
2015-12-13 12:13:03 +01:00
|
|
|
include: /node_modules(\\|\/)(ipfs-api|hoek|qs|boom|wreck)/,
|
2015-11-21 14:35:08 +01:00
|
|
|
loader: 'babel',
|
|
|
|
query: {
|
|
|
|
presets: ['es2015'],
|
2015-12-13 13:30:54 +01:00
|
|
|
plugins: addTransformRuntime([])
|
2015-11-21 14:35:08 +01:00
|
|
|
}
|
2015-11-20 14:20:06 +01:00
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
externals: {
|
2015-11-23 15:13:21 +01:00
|
|
|
net: '{}',
|
|
|
|
fs: '{}',
|
|
|
|
tls: '{}',
|
|
|
|
console: '{}',
|
|
|
|
'require-dir': '{}'
|
2015-11-20 14:20:06 +01:00
|
|
|
},
|
|
|
|
plugins: [
|
|
|
|
new HtmlWebpackPlugin({
|
|
|
|
title: 'Boards',
|
2015-11-21 16:29:54 +01:00
|
|
|
template: 'webapp/index.html',
|
2015-11-20 14:20:06 +01:00
|
|
|
inject: 'body'
|
|
|
|
}),
|
|
|
|
// Optimization
|
|
|
|
new webpack.optimize.OccurenceOrderPlugin(),
|
2015-12-13 13:30:54 +01:00
|
|
|
new webpack.optimize.DedupePlugin(),
|
|
|
|
new webpack.optimize.UglifyJsPlugin({
|
|
|
|
compress: {
|
|
|
|
warnings: false
|
|
|
|
}
|
|
|
|
})
|
2015-11-20 14:20:06 +01:00
|
|
|
]
|
|
|
|
}
|
2015-12-12 11:54:14 +01:00
|
|
|
|
|
|
|
config.devServer = {
|
|
|
|
// webpack-dev-server -w --progress --devtool eval --port 9090 --quiet --content-base ./webapp/dist
|
|
|
|
watch: true,
|
|
|
|
progress: true,
|
|
|
|
debug: true,
|
|
|
|
devtool: 'eval-source',
|
|
|
|
port: 9090,
|
|
|
|
noInfo: true,
|
|
|
|
colors: true,
|
|
|
|
inline: true,
|
|
|
|
contentBase: config.output.path
|
2015-12-13 13:30:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function addTransformRuntime(l){
|
|
|
|
if(process.env.os != 'Windows_NT'){
|
|
|
|
// Workaround for babel6 bug on windows
|
|
|
|
// https://phabricator.babeljs.io/T6670
|
|
|
|
// https://phabricator.babeljs.io/T2954
|
|
|
|
// Disabling uglify on windows does the trick
|
|
|
|
return l.concat('transform-runtime')
|
|
|
|
}
|
|
|
|
return l
|
|
|
|
}
|
2015-12-12 11:54:14 +01:00
|
|
|
|
|
|
|
module.exports = config
|