Skip to content

Commit

Permalink
eslintエラーを修正
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukihiko Okuyama committed Jul 27, 2016
1 parent 097dd34 commit 48f4cd0
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 112 deletions.
7 changes: 4 additions & 3 deletions app/dev/assets/js/src/app.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';

import React from 'react';
import ReactDOM from 'react-dom';
import Hello from './components/Hello';

ReactDOM.render(<Hello name="Sumally" />, document.getElementById('js-app'));
ReactDOM.render(
<Hello name="Sumally" />,
document.getElementById('js-app')
);
16 changes: 9 additions & 7 deletions app/dev/assets/js/src/components/Hello.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
'use strict';

import React from 'react';

export default class Hello extends React.Component {
render() {
return <h1>Hello {this.props.name} !</h1>
}
}
function Hello({ name }) {
return <h1>{name}</h1>;
}

Hello.propTypes = {
name: React.PropTypes.string.isRequired,
};

export default Hello;
35 changes: 15 additions & 20 deletions server.babel.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import opn from 'opn';
import webpack from 'webpack';
import WebpackDevServer from 'webpack-dev-server';
Expand All @@ -9,27 +7,24 @@ const port = 3000;
const url = `http://localhost:${port}`;

webpackConfig.entry.app.unshift(
`webpack-dev-server/client?${url}`,
'webpack/hot/only-dev-server'
`webpack-dev-server/client?${url}`,
'webpack/hot/only-dev-server'
);

webpackConfig.plugins.push(
new webpack.HotModuleReplacementPlugin()
new webpack.HotModuleReplacementPlugin()
);

new WebpackDevServer(webpack(webpackConfig), {
publicPath: webpackConfig.output.publicPath,
contentBase: 'app/dev',
hot: true,
historyApiFallback: true,
stats: {
colors: true,
chunks: false,
},
}).listen(port, 'localhost', (error) => {
if (error) {
return console.log(error);
}

opn(url, {app: 'google chrome'});
});
publicPath: webpackConfig.output.publicPath,
contentBase: 'app/dev',
hot: true,
historyApiFallback: true,
stats: {
colors: true,
chunks: false,
},
}).listen(port, 'localhost', () => {
const options = { app: 'google chrome' };
return opn(url, options);
});
4 changes: 1 addition & 3 deletions server.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
'use strict';

require('babel-register');
require('./server.babel.js');
require('./server.babel.js');
158 changes: 79 additions & 79 deletions webpack.config.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,93 +6,93 @@ import merge from 'webpack-merge';
import CopyWebpackPlugin from 'copy-webpack-plugin';

const config = {
// 開発・リリース用のビルド設定
common: {
context: path.join(__dirname, 'app', 'dev'),
entry: {
app: [
'./assets/js/src/app.jsx',
],
},
module: {
preLoaders: [
{
test: /\.js?$/,
loaders: [
// 開発・リリース用のビルド設定
common: {
context: path.join(__dirname, 'app', 'dev'),
entry: {
app: [
'./assets/js/src/app.jsx',
],
},
module: {
preLoaders: [
{
test: /\.js?$/,
loaders: [

// -loader postfixをつけないとnode_modulesまで対象に含まれてしまう
// ref: http://stackoverflow.com/a/29890656
'source-map-loader',
],
},
],
},
resolve: {
extensions: ['', '.js', '.jsx'],
// -loader postfixをつけないとnode_modulesまで対象に含まれてしまう
// ref: http://stackoverflow.com/a/29890656
'source-map-loader',
],
},
],
},
// 開発用のビルド設定
dev: {
output: {
// 本来は相対パスで問題ないが、
// server.js経由で参照される場合は絶対パスである必要がある
path: path.join(__dirname, 'app', 'dev', 'assets', 'js'),
publicPath: '/assets/js/',
filename: 'app.js',
},
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: [
// -loader postfixをつけないとnode_modulesまで対象に含まれてしまう
// ref: http://stackoverflow.com/a/29890656
'react-hot-loader',
'babel-loader',
],
include: [
path.join(__dirname, 'app'),
],
},
],
},
plugins: [],
devtool: 'inline-source-map',
resolve: {
extensions: ['', '.js', '.jsx'],
},
// リリース用のビルド設定
prod: {
output: {
// 本来は相対パスで問題ないが、
// server.js経由で参照される場合は絶対パスである必要がある
path: path.join(__dirname, 'app', 'prod', 'assets', 'js'),
publicPath: '/assets/js/',
filename: 'app.js',
},
// 開発用のビルド設定
dev: {
output: {
// 本来は相対パスで問題ないが、
// server.js経由で参照される場合は絶対パスである必要がある
path: path.join(__dirname, 'app', 'dev', 'assets', 'js'),
publicPath: '/assets/js/',
filename: 'app.js',
},
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: [
// -loader postfixをつけないとnode_modulesまで対象に含まれてしまう
// ref: http://stackoverflow.com/a/29890656
'react-hot-loader',
'babel-loader',
],
include: [
path.join(__dirname, 'app'),
],
},
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: [
// -loader postfixをつけないとnode_modulesまで対象に含まれてしまう
// ref: http://stackoverflow.com/a/29890656
'babel-loader',
],
},
],
],
},
plugins: [],
devtool: 'inline-source-map',
},
// リリース用のビルド設定
prod: {
output: {
// 本来は相対パスで問題ないが、
// server.js経由で参照される場合は絶対パスである必要がある
path: path.join(__dirname, 'app', 'prod', 'assets', 'js'),
publicPath: '/assets/js/',
filename: 'app.js',
},
module: {
loaders: [
{
test: /\.jsx?$/,
loaders: [
// -loader postfixをつけないとnode_modulesまで対象に含まれてしまう
// ref: http://stackoverflow.com/a/29890656
'babel-loader',
],
},
plugins: [
new CopyWebpackPlugin([
{
from: 'index.html',
to: path.join(__dirname, 'app', 'prod'),
},
]),
],
devtool: 'eval',
],
},
plugins: [
new CopyWebpackPlugin([
{
from: 'index.html',
to: path.join(__dirname, 'app', 'prod'),
},
]),
],
devtool: 'eval',
},
};

export default merge(
config.common,
process.argv.includes('--prod') ? config.prod : config.dev
config.common,
process.argv.includes('--prod') ? config.prod : config.dev
);

0 comments on commit 48f4cd0

Please sign in to comment.