Skip to content

Instantly share code, notes, and snippets.

@ridhwaans
Last active April 1, 2019 16:01
Show Gist options
  • Save ridhwaans/c1f84e3cbae3b6c9b415c309f5b4d52f to your computer and use it in GitHub Desktop.
Save ridhwaans/c1f84e3cbae3b6c9b415c309f5b4d52f to your computer and use it in GitHub Desktop.
webpack config
const path = require('path');
const PATHS = {
src: path.join(__dirname, './src'),
public: path.join(__dirname, './public')
};
var config = {
entry: {
app: [ 'babel-polyfill', path.resolve(PATHS.src, 'index.js') ]
},
output: {
path: path.resolve(PATHS.public),
filename: 'bundle.js',
publicPath: '/'
},
devServer: {
contentBase: path.resolve(PATHS.public),
port: 3000,
historyApiFallback: true,
proxy: {
'/api/**': {
target: 'http://localhost:5000',
changeOrigin: true
}
}
},
module: {
rules: [
{
test: /\.(jpg|png|gif|svg|pdf|ico)$/i,
use: [
{
loader: 'file-loader'
}
]
},
{
test: /\.js$/,
use: [
{
loader: 'babel-loader',
options: { presets: ['@babel/env', '@babel/react', '@babel/stage-2'] }
}
],
exclude: /(node_modules|bower_components)/
},
{ test: /\.css$/,
use: [
{
loader: 'style-loader',
options: { singleton: true }
},
{
loader: 'css-loader',
options: {
modules: false
}
}
],
include: [
/(node_modules|bower_components)/,
path.resolve(PATHS.src, 'style/node_modules.css')
]
},
{
test: /\.css$/,
use: [
{
loader: 'style-loader',
options: { singleton: true }
},
{
loader: 'css-loader',
options: {
modules: true,
camelCase: 'dashes',
localIdentName: '[path][name]__[local]'
}
}
],
exclude: [
/(node_modules|bower_components)/,
path.resolve(PATHS.src, 'style/node_modules.css')
]
}
]
}
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment