Last active
January 4, 2018 09:59
-
-
Save az1979/8a44b9233a7b5856a784be000ffc4c36 to your computer and use it in GitHub Desktop.
Reactが動作するサンプルプロジェクトのwebpack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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