mkdir src www
npm init -f
npm install --save-dev webpack webpack-dev-server
npm install --save-dev babel-core babel-loader babel-preset-es2015
npm install --save-dev babel-preset-stage-0 babel-polyfill
npm install --save-dev babel-preset-react
npm install --save react react-dom react-redux redux redux-thunk
create webpack.config.js:
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: [path.resolve('src/index.js')],
output: {
path: path.resolve('www'),
filename: 'bundle.js',
},
devtool: 'inline-source-map',
devServer: {
contentBase: path.resolve('www'),
port: 3000,
hot: false,
inline: true,
colors: true
},
resolve: {
extensions: ['', '.js'],
},
module: {
loaders:[
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
]
}
};
create .babelrc:
{
"presets": ["react", "es2015", "stage-0"]
}
create www/index.html:
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>title</title>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>
<body>
<div id="root"></div>
<script src="bundle.js"></script>
</body>
</html>
npm install --save jquery bootstrap
npm install --save-dev style-loader file-loader css-loader url-loader
edit webpack.config.js
const path = require('path');
const webpack = require('webpack');
module.exports = {
entry: [path.resolve('src/index.js')],
output: {
path: path.resolve('www'),
filename: 'bundle.js',
},
devtool: 'inline-source-map',
devServer: {
contentBase: path.resolve('www'),
port: 3000,
hot: false,
inline: true,
colors: true
},
resolve: {
extensions: ['', '.js'],
},
module: {
loaders:[
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel' },
{ test: /\.css$/, loader: "style-loader!css-loader" },
{ test: /\.svg$/, loader: 'url-loader?mimetype=image/svg+xml' },
{ test: /\.woff$/, loader: 'url-loader?mimetype=application/font-woff' },
{ test: /\.woff2$/, loader: 'url-loader?mimetype=application/font-woff' },
{ test: /\.eot$/, loader: 'url-loader?mimetype=application/font-woff' },
{ test: /\.ttf$/, loader: 'url-loader?mimetype=application/font-woff' }
]
},
plugins: [
new webpack.ProvidePlugin({
jQuery: 'jquery',
$: "jquery"
})
]
};