Skip to content

Instantly share code, notes, and snippets.

@zackshapiro
Created July 21, 2020 14:24
Show Gist options
  • Save zackshapiro/1878533f3c5e41adf4699c27d98e9ae6 to your computer and use it in GitHub Desktop.
Save zackshapiro/1878533f3c5e41adf4699c27d98e9ae6 to your computer and use it in GitHub Desktop.
const webpack = require('webpack');
const path = require('path');
const BabiliPlugin = require('babili-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
// Config directories
const SRC_DIR = path.resolve(__dirname, 'src');
const ASSETS_DIR = path.resolve(__dirname, 'assets');
const OUTPUT_DIR = path.resolve(__dirname, 'dist');
// Any directories you will be adding code/files into, need to be added to this array so webpack will pick them up
const defaultInclude = [SRC_DIR, ASSETS_DIR];
module.exports = {
entry: SRC_DIR + '/index.js',
output: {
path: OUTPUT_DIR,
publicPath: './',
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.css$/,
loader: 'style-loader!css-loader',
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader',
},
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015', 'stage-3'],
},
},
{
test: /\.(ttf|eot|otf|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
},
],
},
target: 'electron-renderer',
plugins: [
new ExtractTextPlugin('bundle.css'),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production'),
}),
new BabiliPlugin(),
],
stats: {
colors: true,
children: false,
chunks: false,
modules: false,
},
};
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
// Config directories
const SRC_DIR = path.resolve(__dirname, 'src');
const ASSETS_DIR = path.resolve(__dirname, 'assets');
const OUTPUT_DIR = path.resolve(__dirname, 'dist');
// Any directories you will be adding code/files into, need to be added to this array so webpack will pick them up
const defaultInclude = [SRC_DIR];
module.exports = {
entry: ['babel-polyfill', SRC_DIR + '/index.js'],
output: {
path: OUTPUT_DIR,
publicPath: '/',
filename: 'bundle.js',
},
module: {
rules: [
{
test: /\.css$/,
loader: 'style-loader!css-loader',
},
{
test: /\.scss$/,
loader: 'style-loader!css-loader!sass-loader',
},
{
test: /\.jsx?$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.jsx?$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: ['react', 'es2015', 'stage-3'],
},
},
{
test: /\.(jpe?g|png|gif|svg)$/i,
loader: 'file-loader',
},
{
test: /.(ttf|eot|otf)(\?v=[0-9].[0-9].[0-9])?$/,
loader: 'file-loader',
},
],
},
target: 'electron-renderer',
plugins: [
new HtmlWebpackPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
}),
new webpack.LoaderOptionsPlugin({
options: {
eslint: { failOnWarning: false, failOnError: true },
},
}),
],
devtool: 'cheap-source-map',
devServer: {
contentBase: OUTPUT_DIR,
stats: {
colors: true,
chunks: false,
children: false,
},
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment