forked from tabwrangler/tabwrangler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
84 lines (81 loc) · 2.32 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/* eslint-env node */
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextPlugin = require('extract-text-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const COMMON_CONFIG = {
entry: {
background: './app/background.js',
popup: './app/popup.js',
},
module: {
rules: [
{
exclude: /node_modules/,
loader: 'babel-loader',
test: /\.js$/,
},
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
fallback: 'style-loader',
use: 'css-loader',
}),
},
{
test: /\.(eot|svg|ttf|woff|woff2)$/,
use: ['file-loader'],
},
],
},
plugins: [
new CopyWebpackPlugin([
{ from: '_locales/**' },
{ from: 'app/img/', to: 'img/' },
{ from: 'app/manifest.json' },
{ from: 'MIT-LICENSE.txt'} ,
{ from: 'README.md' },
]),
new ExtractTextPlugin('popup.css'),
new webpack.optimize.CommonsChunkPlugin('commons'),
new HtmlWebpackPlugin({
cache: false, // Disable cache to ensure file is always created in multi-compiler build
chunks: ['commons', 'popup'],
filename: 'popup.html',
template: './app/popup.template.html',
}),
new HtmlWebpackPlugin({
cache: false, // Disable cache to ensure file is always created in multi-compiler build
chunks: ['commons', 'background'],
filename: 'background.html',
template: './app/background.template.html',
}),
],
};
module.exports = [
Object.assign({}, COMMON_CONFIG, {
name: 'chrome',
output: {
path: path.join(__dirname, 'dist', 'chrome'),
filename: '[name].entry.js',
},
plugins: COMMON_CONFIG.plugins.concat([
new webpack.DefinePlugin({
EXTENSION_URL: JSON.stringify('https://chrome.google.com/webstore/detail/egnjhciaieeiiohknchakcodbpgjnchh/'),
}),
]),
}),
Object.assign({}, COMMON_CONFIG, {
name: 'firefox',
output: {
path: path.join(__dirname, 'dist', 'firefox'),
filename: '[name].entry.js',
},
plugins: COMMON_CONFIG.plugins.concat([
new webpack.DefinePlugin({
EXTENSION_URL: JSON.stringify('https://addons.mozilla.org/en-US/firefox/addon/tabwrangler/'),
}),
]),
}),
];