Skip to content

Instantly share code, notes, and snippets.

@az1979
Last active January 4, 2018 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save az1979/8a44b9233a7b5856a784be000ffc4c36 to your computer and use it in GitHub Desktop.
Save az1979/8a44b9233a7b5856a784be000ffc4c36 to your computer and use it in GitHub Desktop.
Reactが動作するサンプルプロジェクトのwebpack.config.js
const webpack = require('webpack');
const path = require('path');
// 環境を記述 development or production
const env = 'development';
const config = {
entry: './entry.jsx',
output: {
path: path.join(__dirname, '/dist'),
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
]
},
resolve: {
extensions: ['.js', '.json', '.jsx', 'css']
},
plugins: [
new webpack.EnvironmentPlugin({
NODE_ENV: env
}),
],
devtool: 'source-map'
};
// Production ビルドの場合は圧縮する
if (env === 'production') {
config.plugins.push(
new webpack.optimize.UglifyJsPlugin()
);
}
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment