mirror of https://github.com/jiahaog/Nativefier
Implement gulp webpack to build app
This commit is contained in:
parent
9c0e65e89f
commit
ddd728bd81
|
@ -1 +0,0 @@
|
|||
Placeholder file here to commit the lib folder, as we cannot mkdir -p on Windows
|
|
@ -2,6 +2,7 @@
|
|||
* Created by JiaHao on 4/7/15.
|
||||
*/
|
||||
|
||||
console.log('hihi');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var electron = require('electron');
|
||||
|
@ -12,6 +13,7 @@ var helpers = require('./helpers/helpers');
|
|||
var app = electron.app;
|
||||
var isOSX = helpers.isOSX;
|
||||
|
||||
console.log('dirname', __dirname);
|
||||
const APP_ARGS_FILE_PATH = path.join(__dirname, '..', 'nativefier.json');
|
||||
|
||||
var appArgs = JSON.parse(fs.readFileSync(APP_ARGS_FILE_PATH, 'utf8'));
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
import gulp from 'gulp';
|
||||
import del from 'del';
|
||||
import sourcemaps from 'gulp-sourcemaps';
|
||||
import webpack from 'webpack-stream';
|
||||
import babel from 'gulp-babel';
|
||||
import watchify from 'watchify';
|
||||
import runSequence from 'run-sequence';
|
||||
|
||||
gulp.task('default', ['build']);
|
||||
|
||||
gulp.task('build', callback => {
|
||||
runSequence('clean', ['build-cli', 'build-app'], callback);
|
||||
});
|
||||
|
||||
gulp.task('build-app', ['build-static'], function () {
|
||||
return gulp.src('app/src/main.js')
|
||||
.pipe(webpack(require('./webpack.config.js')))
|
||||
.pipe(gulp.dest('app/lib'));
|
||||
});
|
||||
|
||||
gulp.task('clean', callback => {
|
||||
del('lib').then(() => {
|
||||
del('app/lib').then(() => {
|
||||
callback();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
gulp.task('build-cli', () => {
|
||||
return gulp.src("src/**/*.js")
|
||||
.pipe(sourcemaps.init())
|
||||
.pipe(babel())
|
||||
.pipe(sourcemaps.write('.'))
|
||||
.pipe(gulp.dest('lib'));
|
||||
});
|
||||
|
||||
gulp.task('build-static', () => {
|
||||
// copy any html files in source/ to public/
|
||||
return gulp.src('app/src/static/**/*')
|
||||
.pipe(gulp.dest('app/lib/static/'));
|
||||
});
|
14
package.json
14
package.json
|
@ -20,7 +20,10 @@
|
|||
"prepublish": "npm run build",
|
||||
"package-placeholder": "npm run build && node lib/cli.js http://www.medium.com ~/Desktop --overwrite && open ~/Desktop/Medium-darwin-x64/Medium.app",
|
||||
"start-placeholder": "npm run build && electron app",
|
||||
"debug-auth": "npm run build && node lib/cli.js http://feedly.com/i/welcome ~/Desktop --overwrite --app-name feedly && open ~/Desktop/feedly-darwin-x64/feedly.app"
|
||||
"debug-auth": "npm run build && node lib/cli.js http://feedly.com/i/welcome ~/Desktop --overwrite --app-name feedly && open ~/Desktop/feedly-darwin-x64/feedly.app",
|
||||
"start-webpack": "electron app",
|
||||
"gulp": "gulp",
|
||||
"clean": "gulp clean"
|
||||
},
|
||||
"bin": {
|
||||
"nativefier": "lib/cli.js"
|
||||
|
@ -54,7 +57,12 @@
|
|||
"devDependencies": {
|
||||
"babel-cli": "^6.4.0",
|
||||
"babel-preset-es2015": "^6.3.13",
|
||||
"browserify": "^13.0.0",
|
||||
"electron-prebuilt": "^0.36.4"
|
||||
"babelify": "^7.2.0",
|
||||
"del": "^2.2.0",
|
||||
"gulp": "^3.9.0",
|
||||
"gulp-babel": "^6.1.1",
|
||||
"gulp-sourcemaps": "^1.6.0",
|
||||
"run-sequence": "^1.1.5",
|
||||
"webpack-stream": "^3.1.0"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
|
||||
var fs = require('fs');
|
||||
var nodeModules = {};
|
||||
fs.readdirSync('node_modules')
|
||||
.filter(function(x) {
|
||||
return ['.bin'].indexOf(x) === -1;
|
||||
})
|
||||
.forEach(function(mod) {
|
||||
nodeModules[mod] = 'commonjs ' + mod;
|
||||
});
|
||||
|
||||
console.log(nodeModules);
|
|
@ -0,0 +1,29 @@
|
|||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
//http://jlongster.com/Backend-Apps-with-Webpack--Part-I
|
||||
// set all modules in node_modules as external
|
||||
var nodeModules = {};
|
||||
fs
|
||||
.readdirSync('./app/node_modules')
|
||||
.filter(function (x) {
|
||||
return ['.bin'].indexOf(x) === -1;
|
||||
})
|
||||
.forEach(function (mod) {
|
||||
nodeModules[mod] = 'commonjs ' + mod;
|
||||
});
|
||||
|
||||
// add electron to external module
|
||||
nodeModules['electron'] = 'commonjs electron';
|
||||
|
||||
module.exports = {
|
||||
target: 'node',
|
||||
output: {
|
||||
filename: 'main.js'
|
||||
},
|
||||
node: {
|
||||
global: false,
|
||||
__dirname: false
|
||||
},
|
||||
externals: nodeModules
|
||||
};
|
Loading…
Reference in New Issue