Last active
May 31, 2018 07:24
-
-
Save jsartisan/0fb8c3224b77a43c993f8311fdb6c855 to your computer and use it in GitHub Desktop.
Optimizing and Managing a Chrome Extension with Webpack
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
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