Last active
February 7, 2017 18:02
-
-
Save colde/a0db7ca1a2d0a4596bc10241a6c55740 to your computer and use it in GitHub Desktop.
Webpack config for django
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
var path = require('path'); | |
var webpack = require('webpack'); | |
var BundleTracker = require('webpack-bundle-tracker'); | |
var ExtractTextPlugin = require("extract-text-webpack-plugin"); | |
module.exports = { | |
context: __dirname, | |
entry: [ | |
'webpack-dev-server/client?http://0.0.0.0:3000', // WebpackDevServer host and port | |
'webpack/hot/only-dev-server', // "only" prevents reload on syntax errors | |
'./assets/js/index' | |
], | |
output: { | |
path: path.resolve('./assets/webpack_bundles/'), | |
filename: "[name]-[hash].js", | |
publicPath: 'http://localhost:3000/assets/bundles/', // Tell django to use this URL to load packages and not use STATIC_URL + bundle_name | |
}, | |
plugins: [ | |
new webpack.HotModuleReplacementPlugin(), | |
//new ExtractTextPlugin("styles.css"), | |
new BundleTracker({filename: './webpack-stats.json'}) | |
], | |
module: { | |
loaders: [ | |
{ | |
test: /\.jsx?$/, | |
exclude: /(node_modules|bower_components)/, | |
loaders: ['react-hot-loader', 'babel-loader?presets[]=es2015,presets[]=react'], | |
}, | |
{ | |
test: /\.js$/, | |
exclude: /(node_modules|bower_components)/, | |
loaders: ['react-hot-loader', 'babel-loader?presets[]=es2015,presets[]=react'], | |
}, | |
{ | |
test: /\.css$/, | |
exclude: /(node_modules|bower_components)/, | |
//loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader' }) | |
loader: "style-loader!css-loader" | |
}, | |
{ | |
test: /\.scss$/, | |
exclude: /(node_modules|bower_components)/, | |
//loader: ExtractTextPlugin.extract({ fallback: 'style-loader', use: 'css-loader|sass-loader' }) | |
loader: "style-loader!css-loader!sass-loader" | |
}, | |
{ | |
test: /\.(png|woff|woff2|eot|ttf|svg)$/, | |
loader: "url-loader" | |
} | |
], | |
}, | |
resolve: { | |
modules: ['assets/js', 'node_modules', 'bower_components'], | |
extensions: ['.js', '.jsx'] | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment