1
0
mirror of https://github.com/fazo96/ipfs-boards synced 2025-01-10 12:24:20 +01:00
ipfs-boards/webpack.config.js

112 lines
2.7 KiB
JavaScript
Raw Normal View History

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'),
2015-11-20 14:20:06 +01:00
filename: 'app.js'
},
resolve: {
modulesDirectories: [
2015-11-21 16:29:54 +01:00
'node_modules', './webapp/', 'lib', './webapp/components/', './webapp/assets/',
'./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,
fix: true
2015-12-14 00:06:12 +01:00
},
2015-11-20 14:20:06 +01:00
module: {
2015-12-14 00:06:12 +01:00
preLoaders: [
{
test: /\.jsx?$/,
loader: 'eslint-loader',
2015-12-22 14:00:22 +01:00
exclude: /node_modules|webapp\/dist\//
2015-12-14 00:06:12 +01:00
}
],
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'] },
{ 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: '{}',
2015-12-12 17:51:03 +01:00
fs: '{ lstat: function(){} }',
2015-11-23 15:13:21 +01:00
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,
2015-12-15 17:12:53 +01:00
hot: true,
2015-12-12 11:54:14 +01:00
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-13 13:30:54 +01:00
}
2015-12-12 11:54:14 +01:00
module.exports = config