Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tsuwatch committed Nov 4, 2016
0 parents commit 53b5a36
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"presets": [
"es2015",
"react"
]
}
18 changes: 18 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parser": "babel-eslint",
"plugins": [
"react"
],
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
"rules": {
}
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app
52 changes: 52 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"name": "nicomentron",
"version": "0.1.0",
"description": "comments viewer for live.nicovideo.jp",
"main": "app/main.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"lint": "./node_modules/.bin/eslint ./src",
"build": "npm run build:main && npm run build:renderer",
"build:main": "cross-env NODE_ENV=production node -r babel-register ./node_modules/.bin/webpack --config webpack.config.electron.js --progress --profile --colors",
"build:renderer": "cross-env NODE_ENV=production node -r babel-register ./node_modules/.bin/webpack --config webpack.config.production.js --progress --profile --colors",
"start": "./node_modules/.bin/electron .",
"start:dev": "cross-env NODE_ENV=development electron -r babel-register ./src/main.js",
"watch": "cross-env NODE_ENV=development node -r babel-register ./node_modules/.bin/webpack-dev-server --config webpack.config.development.js",
"dev": "./node_modules/.bin/npm-run-all -p watch start:dev"
},
"repository": {
"type": "git",
"url": "git+https://github.com/tsuwatch/nicomentron.git"
},
"author": "tsuwatch",
"license": "ISC",
"bugs": {
"url": "https://github.com/tsuwatch/nicomentron/issues"
},
"homepage": "https://github.com/tsuwatch/nicomentron#readme",
"dependencies": {
"nicolive": "0.0.4",
"react": "^15.3.2",
"react-dom": "^15.3.2"
},
"devDependencies": {
"babel": "^6.5.2",
"babel-core": "^6.18.0",
"babel-eslint": "^7.1.0",
"babel-loader": "^6.2.7",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-register": "^6.18.0",
"concurrently": "^3.1.0",
"cross-env": "^3.1.3",
"electron-prebuilt": "^1.3.8",
"eslint": "^3.9.1",
"eslint-plugin-react": "^6.5.0",
"html-webpack-plugin": "^2.24.1",
"npm-run-all": "^3.1.1",
"react-hot-loader": "^3.0.0-beta.6",
"webpack": "^1.13.3",
"webpack-dev-server": "^1.16.2",
"webpack-merge": "^0.15.0"
}
}
10 changes: 10 additions & 0 deletions src/components/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';

export default class App extends React.Component {
render() {
return (
<div>
</div>
);
}
}
19 changes: 19 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Nicomentron</title>
<meta charset="utf-8">
</head>
<body>
<div id="root"></div>
<script>
{
const script = document.createElement('script');
const port = process.env.PORT || 3000;
script.src = process.env.NODE_ENV === 'development' ?
'http://localhost:' + port + '/index.js' : 'index.js';
document.write(script.outerHTML);
}
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import App from './components/App';
import React from 'react';
import ReactDOM from 'react-dom';

ReactDOM.render(<App />, document.getElementById('root'));
23 changes: 23 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import {app, BrowserWindow} from 'electron';

let mainWindow = null;

app.on('ready', () => {
if (mainWindow) return;

mainWindow = new BrowserWindow({width: 800, height: 600});
mainWindow.loadURL(`file://${__dirname}/../src/index.html`);
mainWindow.on('closed', () => {
mainWindow = null;
});

if (process.env.NODE_ENV === 'development') {
mainWindow.openDevTools();
}
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
19 changes: 19 additions & 0 deletions webpack.config.base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import path from 'path';

export default {
output: {
path: path.join(__dirname, 'app'),
filename : 'bundle.js',
libraryTarget: 'commonjs2'
},
resolve: {
extensions: ['', '.js', 'jsx']
},
module: {
loaders: [{
test : /\.jsx?$/,
loaders: ['babel-loader'],
exclude: /node_modules/
}]
}
};
34 changes: 34 additions & 0 deletions webpack.config.development.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import path from 'path';
import webpack from 'webpack';
import merge from 'webpack-merge';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import baseConfig from './webpack.config.base';

const port = process.env.PORT || 3000;

export default merge(baseConfig, {
debug: true,
devtool: 'cheap-module-eval-source-map',
entry: {
app: ['./src/index']
},
output: {
path: path.join(__dirname, 'app'),
filename : 'index.js',
publicPath: `http://localhost:${port}/`
},
plugins: [
new webpack.HotModuleReplacementPlugin(),
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
inject: false
})
],
devServer: {
port: port,
inline: true,
colors: true
},
target: 'electron-renderer'
});
14 changes: 14 additions & 0 deletions webpack.config.electron.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import path from 'path';
import webpack from 'webpack';
import merge from 'webpack-merge';
import baseConfig from './webpack.config.base';

export default merge(baseConfig, {
devtool: 'source-map',
entry: ['./src/main'],
output: {
path: path.join(__dirname, 'app'),
filename : 'main.js',
},
target: 'electron-main',
});
22 changes: 22 additions & 0 deletions webpack.config.production.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import path from 'path';
import webpack from 'webpack';
import merge from 'webpack-merge';
import HtmlWebpackPlugin from 'html-webpack-plugin';
import baseConfig from './webpack.config.base';

export default merge(baseConfig, {
devtool: 'cheap-module-eval-source-map',
entry: ['./src/index'],
output: {
path: path.join(__dirname, 'app'),
filename : 'index.js',
},
plugins: [
new HtmlWebpackPlugin({
filename: 'index.html',
template: 'src/index.html',
inject: false
})
],
target: 'electron-renderer'
});

0 comments on commit 53b5a36

Please sign in to comment.