mirror of
https://github.com/fazo96/ipfs-boards
synced 2025-03-11 21:38:38 +01:00
switched from browserify to webpack
This commit is contained in:
parent
a5ef878043
commit
c417e42c1a
86
gulpfile.js
86
gulpfile.js
@ -1,14 +1,7 @@
|
||||
var gulp = require('gulp')
|
||||
var source = require('vinyl-source-stream')
|
||||
var buffer = require('vinyl-buffer')
|
||||
var minifyCss = require('gulp-minify-css')
|
||||
var browserify = require('browserify')
|
||||
var uglify = require('gulp-uglify')
|
||||
var webpack = require('webpack-stream')
|
||||
var clean = require('gulp-clean')
|
||||
var exorcist = require('exorcist')
|
||||
var connect = require('gulp-connect')
|
||||
var watchify = require('watchify')
|
||||
var util = require('gulp-util')
|
||||
var ghPages = require('gulp-gh-pages')
|
||||
|
||||
var config = {
|
||||
@ -22,64 +15,21 @@ var config = {
|
||||
dest: 'webapp/dist/'
|
||||
}
|
||||
|
||||
gulp.task('css',function(){
|
||||
gulp.src(config.files.css)
|
||||
.pipe(minifyCss())
|
||||
.pipe(gulp.dest(config.dest))
|
||||
.pipe(connect.reload())
|
||||
gulp.task('watch',function(){
|
||||
var cfg = require('./webpack.config.js')
|
||||
cfg.watch = true
|
||||
return gulp.src(config.files.mainJs)
|
||||
.pipe(webpack(cfg))
|
||||
.pipe(gulp.dest(config.dest))
|
||||
.pipe(connect.reload())
|
||||
})
|
||||
|
||||
gulp.task('html',function(){
|
||||
return gulp.src(config.files.html)
|
||||
.pipe(gulp.dest(config.dest))
|
||||
.pipe(connect.reload())
|
||||
gulp.task('build',function(){
|
||||
return gulp.src(config.files.mainJs)
|
||||
.pipe(webpack(require('./webpack.config.js')))
|
||||
.pipe(gulp.dest(config.dest))
|
||||
})
|
||||
|
||||
gulp.task('js-watch',function(){
|
||||
var b = getBrowserify()
|
||||
b.on('log',function(l){
|
||||
util.log(l)
|
||||
})
|
||||
b.on('error',function(error){
|
||||
util.log(error)
|
||||
})
|
||||
b.on('update', function(){
|
||||
util.log('Rebundling')
|
||||
applyBrowserify(b)
|
||||
})
|
||||
return applyBrowserify(b)
|
||||
})
|
||||
|
||||
gulp.task('js',function(){
|
||||
return applyBrowserify(getBrowserify())
|
||||
})
|
||||
|
||||
function getBrowserify(){
|
||||
return browserify(config.files.mainJs, {
|
||||
cache: {},
|
||||
packageCache: {},
|
||||
plugin: [watchify],
|
||||
//fullPaths: true,
|
||||
debug: true })
|
||||
.transform('babelify', {
|
||||
global: true,
|
||||
presets: [ 'es2015', 'react' ],
|
||||
ignore: /buffer|EventEmitter/
|
||||
})
|
||||
.transform('eslintify')
|
||||
.transform({ global: true },'uglifyify')
|
||||
}
|
||||
|
||||
function applyBrowserify(b){
|
||||
return b.bundle()
|
||||
.pipe(exorcist(__dirname+'/webapp/dist/app.js.map'))
|
||||
.on('error', console.error.bind(console))
|
||||
.pipe(source('app.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(gulp.dest(config.dest))
|
||||
.pipe(connect.reload())
|
||||
}
|
||||
|
||||
gulp.task('clean',function(){
|
||||
return gulp.src(config.dest, { read: false }).pipe(clean())
|
||||
})
|
||||
@ -92,17 +42,11 @@ gulp.task('server',function(){
|
||||
})
|
||||
})
|
||||
|
||||
gulp.task('watch',['js-watch'],function(){
|
||||
//gulp.watch([config.files.jsLibs,config.files.mainJs],['js-watch'])
|
||||
gulp.watch(config.files.html,['html'])
|
||||
gulp.watch(config.files.css,['css'])
|
||||
})
|
||||
|
||||
gulp.task('gh-pages',[ 'html', 'css', 'js' ],function(){
|
||||
gulp.task('gh-pages',[ 'build' ],function(){
|
||||
gulp.src([config.dest+'*.js',config.dest+'*.css',config.dest+'*.html'])
|
||||
.pipe(ghPages())
|
||||
})
|
||||
|
||||
gulp.task('serve', [ 'html', 'css', 'watch', 'server' ])
|
||||
gulp.task('serve', [ 'watch', 'server' ])
|
||||
|
||||
gulp.task('default', [ 'html', 'css', 'js' ])
|
||||
gulp.task('default', [ 'build' ])
|
||||
|
22
package.json
22
package.json
@ -20,34 +20,32 @@
|
||||
"author": "Enrico Fasoli (fazo96)",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"babel-core": "~6.2.1",
|
||||
"babel-loader": "~6.2.0",
|
||||
"babel-preset-es2015": "~6.1.18",
|
||||
"babel-preset-react": "~6.1.18",
|
||||
"babelify": "~7.2.0",
|
||||
"browserify": "~12.0.1",
|
||||
"commander": "~2.9.0",
|
||||
"css-loader": "~0.23.0",
|
||||
"eslint": "~1.9.0",
|
||||
"eslint-plugin-react": "~3.9.0",
|
||||
"eslintify": "~0.0.3",
|
||||
"exorcist": "~0.4.0",
|
||||
"file-loader": "^0.8.4",
|
||||
"font-awesome": "^4.4.0",
|
||||
"gulp": "~3.9.0",
|
||||
"gulp-clean": "~0.3.1",
|
||||
"gulp-connect": "~2.2.0",
|
||||
"gulp-gh-pages": "^0.5.4",
|
||||
"gulp-minify-css": "~1.2.1",
|
||||
"gulp-uglify": "~1.5.1",
|
||||
"gulp-util": "~3.0.7",
|
||||
"gulp-gh-pages": "~0.5.4",
|
||||
"history": "~1.13.1",
|
||||
"ipfs-api": "~2.9.0",
|
||||
"json-loader": "~0.5.3",
|
||||
"lodash.sortedindex": "~3.1.1",
|
||||
"moment": "~2.10.6",
|
||||
"react": "~0.14.2",
|
||||
"react-dom": "~0.14.2",
|
||||
"react-markdown": "~1.0.5",
|
||||
"react-router": "~1.0.0",
|
||||
"uglifyify": "~3.0.1",
|
||||
"vinyl-buffer": "~1.0.0",
|
||||
"vinyl-source-stream": "~1.1.0",
|
||||
"watchify": "~3.6.1",
|
||||
"style-loader": "~0.13.0",
|
||||
"webpack": "~1.12.6",
|
||||
"webpack-stream": "~2.1.1",
|
||||
"wolfy87-eventemitter": "~4.3.0"
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,13 @@ var Link = require('react-router').Link
|
||||
var MarkdownLib = require('react-markdown')
|
||||
var moment = require('moment')
|
||||
var sortedIndex = require('lodash.sortedindex')
|
||||
var BoardsAPI = require('../lib/boards-api.js')
|
||||
var BoardsAPI = require('boards-api.js')
|
||||
|
||||
// Load CSS
|
||||
require('normalize.css')
|
||||
require('skeleton.css')
|
||||
require('style.css')
|
||||
require('font-awesome.min.css')
|
||||
|
||||
var opt, s = localStorage.getItem('ipfs-boards-settings')
|
||||
try {
|
||||
|
@ -1,19 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>IPFS Board</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="normalize.css">
|
||||
<link rel="stylesheet" href="skeleton.css">
|
||||
<link rel="stylesheet" href="style.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="root">
|
||||
<div id="loading">
|
||||
<i class="fa fa-3x fa-cog fa-spin"></i>
|
||||
</div>
|
||||
</div>
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
12
webapp/template.html
Normal file
12
webapp/template.html
Normal file
@ -0,0 +1,12 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>{%= o.htmlWebpackPlugin.options.title %}</title>
|
||||
<link href="//fonts.googleapis.com/css?family=Raleway:400,300,600" rel="stylesheet" type="text/css">
|
||||
<div id="root"></div>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
66
webpack.config.js
Normal file
66
webpack.config.js
Normal file
@ -0,0 +1,66 @@
|
||||
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
|
||||
|
||||
module.exports = {
|
||||
entry: './webapp/app.jsx',
|
||||
debug: true,
|
||||
output: {
|
||||
path: path.join(__dirname,'webapp','dist'),
|
||||
filename: 'app.js'
|
||||
},
|
||||
resolve: {
|
||||
modulesDirectories: [
|
||||
'node_modules', './webapp/', 'lib',
|
||||
'node_modules/font-awesome/css', 'node_modules/font-awesome/fonts'
|
||||
],
|
||||
alias: {
|
||||
http: 'stream-http',
|
||||
https: 'https-browserify'
|
||||
}
|
||||
},
|
||||
module: {
|
||||
loaders: [
|
||||
{ test: /\.(ttf|eot|svg|woff(2?))(\?v=\d+\.\d+\.\d+)?$/, loader: 'file' },
|
||||
{ test: /\.css$/, loaders: ['style','css'] },
|
||||
{ test: /\.json$/, loader: 'json' },
|
||||
{
|
||||
test: /\.jsx?$/,
|
||||
exclude: /(node_modules|bower_components)/,
|
||||
loader: 'babel',
|
||||
query: {
|
||||
presets: ['es2015','react'],
|
||||
plugins: ['transform-runtime']
|
||||
}
|
||||
},{
|
||||
test: /\.js$/,
|
||||
include: /node_modules\/(ipfs-api|hoek|qs|boom|wreck)/,
|
||||
loader: 'babel',
|
||||
query: {
|
||||
presets: ['es2015'],
|
||||
plugins: ['transform-runtime']
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
externals: {
|
||||
fs: '{}'
|
||||
},
|
||||
plugins: [
|
||||
new HtmlWebpackPlugin({
|
||||
title: 'Boards',
|
||||
template: 'webapp/template.html',
|
||||
inject: 'body'
|
||||
}),
|
||||
// Optimization
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
compress: {
|
||||
warnings: false
|
||||
}
|
||||
}),
|
||||
new webpack.optimize.OccurenceOrderPlugin(),
|
||||
new webpack.optimize.DedupePlugin()
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user