Last active
May 29, 2017 00:56
-
-
Save upvalue/91fce38d4159ffaff770c303f099ff63 to your computer and use it in GitHub Desktop.
webpack + babel + react
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
// webpack.config.js - webpack 2 + babel + react + separate LESS to css file config | |
// Required packages: | |
// yarn add --dev webpack babel-loader babel-core babel-preset-es2015 babel-preset-react extract-text-webpack-plugin less css-loader style-loader less-loader | |
const ExtractTextPlugin = require('extract-text-webpack-plugin'); | |
module.exports = { | |
entry: './src/index.js', | |
output: { | |
filename: './build/bundle.js', | |
// For multiple entry points or hash: bundle-[name]-[hash].js | |
}, | |
module: { | |
rules: [ | |
{ | |
test: /.jsx?$/, | |
exclude: /node_modules/, | |
use: { | |
loader: 'babel-loader', | |
options: { | |
presets: ['es2015', 'react'] | |
}, | |
}, | |
}, | |
{ | |
test: /\.less$/, | |
exclude: /node_modules/, | |
use: ExtractTextPlugin.extract({ | |
fallback: 'style-loader', | |
use: ['css-loader', 'less-loader'], | |
}), | |
}, | |
], | |
}, | |
plugins: [ | |
new ExtractTextPlugin('./build/style.css'), | |
], | |
devtool: 'source-map', | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment