Last active
February 28, 2016 16:07
-
-
Save natac13/209a63d0243e5c9f2d85 to your computer and use it in GitHub Desktop.
My Webpack Configuration file. Development
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
import path from 'path' | |
import webpack from 'webpack' | |
import autoprefixer from 'autoprefixer' | |
import ExtractTextPlugin from 'extract-text-webpack-plugin' | |
import HtmlWebpackPlugin from 'html-webpack-plugin' | |
import NpmInstallPlugin from 'npm-install-webpack-plugin' | |
const buildPath = path.join(__dirname, 'build') | |
const entry = path.join(__dirname, 'app', 'index.js') | |
module.exports = { | |
context: __dirname, | |
devtool: 'inline-source-map', | |
entry: [ | |
// sets up an ES6-ish environment with promise support | |
'babel-polyfill', | |
// webpack-hot-middleware needs this | |
'webpack-hot-middleware/client', | |
// the main application script | |
entry | |
], | |
output: { | |
path: buildPath, | |
filename: 'bundle.js', | |
publicPath: '/build/' // need for hot reload. or hit refresh each time | |
}, | |
resolve: { | |
extensions: ['', '.js', '.jsx', '.css', '.scss', '.json', '.node', '.png'] | |
}, | |
module: { | |
loaders: [ | |
{ | |
test: /\.jsx?$/, | |
exclude: /(node_modules)/, | |
loader: 'babel', | |
query: { | |
cacheDirectory: true, | |
presets: ['es2015', 'stage-0', 'react'] | |
} | |
}, | |
{ | |
test: /\.css$/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader') | |
}, | |
{ | |
test: /\.scss$/, | |
loader: ExtractTextPlugin.extract('style-loader', 'css-loader?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]!postcss!sass!toolbox') | |
}, | |
{ | |
test: /\.json$/, | |
loader: 'json' | |
}, | |
{ | |
test: /\.node$/, | |
loader: 'node-loader' | |
}, | |
{ | |
test: /\.(jpe?g|png|gif)$/, | |
loaders: [ | |
'file?hash=sha512&digest=hex&name=[name]_[hash].[ext]', | |
'image-webpack?bypassOnDebug&optimizationLevel=7&interlaced=false' | |
] | |
}, | |
{ | |
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: 'url-loader?limit=10000&mimetype=application/font-woff' | |
}, | |
{ | |
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/, | |
loader: 'file-loader' | |
} | |
] | |
}, | |
postcss: [autoprefixer], | |
toolbox: { theme: 'theme.scss' }, | |
plugins: [ | |
new ExtractTextPlugin('style.css', { allChunk: true }), | |
new HtmlWebpackPlugin({ | |
template: './app/index.html' | |
}), | |
new NpmInstallPlugin({ | |
save: true, | |
saveDev: true | |
}), | |
new webpack.HotModuleReplacementPlugin(), | |
new webpack.NoErrorsPlugin(), | |
new webpack.DefinePlugin({ | |
'process.env': { | |
'NODE_ENV': JSON.stringify('development') | |
} | |
}) | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment