Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jsartisan/0fb8c3224b77a43c993f8311fdb6c855 to your computer and use it in GitHub Desktop.
Save jsartisan/0fb8c3224b77a43c993f8311fdb6c855 to your computer and use it in GitHub Desktop.
Optimizing and Managing a Chrome Extension with Webpack
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const isDevelopment = process.env.NODE_ENV === 'development';
let plugins = [];
const config = {
entry: {
bundle: './src/index.js',
},
output: {
filename: isDevelopment ? '[name].js' : '[name]-[hash].js',
path: path.resolve(__dirname, 'build'),
},
module: {
rules: [
{
test: /\.js?$/,
loader: 'babel-loader',
exclude: /node_modules/,
options: {
presets: [
['env', { targets: { browser: ['last 2 versions'] } }],
'react',
'stage-2',
],
},
},
{
test: /\.css$/,
loader: ExtractTextPlugin.extract({
use: [
{
loader: 'css-loader',
},
],
}),
},
],
},
plugins: [
new HtmlWebpackPlugin({
template: 'src/index.html',
}),
new ExtractTextPlugin('[name].css'),
...plugins,
],
};
module.exports = config;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment