-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
85 lines (81 loc) · 2.19 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
85
const path = require('path');
const webpack = require('webpack');
const MinifyPlugin = require('babel-minify-webpack-plugin');
const WriteFilePlugin = require('write-file-webpack-plugin');
const WebpackShellPlugin = require('webpack-shell-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const host = "localhost";
const port = 8080;
const IS_PRODUCTION = process.env.NODE_ENV === 'production';
const IS_EXT = process.env.NODE_ENV === 'ext';
const dist = IS_PRODUCTION ? 'prod' : 'dev';
const DIST_DIR = path.resolve(__dirname, dist)
const SRC_DIR = path.resolve(__dirname, 'src');
const ASSET_EXTENSIONS = ['jpg', 'jpeg', 'png', 'gif', 'eot', 'otf', 'svg', 'ttf', 'woff', 'woff2'];
module.exports = {
context: SRC_DIR,
entry: {
popup: './extension/popup',
highlight: './extension/highlight',
background: ['./extension/background', './store/store'],
app: './app/app',
},
output: {
filename: '[name].bundle.js',
path: path.join(__dirname, `./${dist}`)
},
devServer: {
host: host,
port: port,
overlay: true,
publicPath: '/dev/',
// contentBase: DIST_DIR
},
resolve: {
extensions: ['.js','.jsx']
},
module: {
rules: [
{
test: /\.css$/,
use: [
'style-loader',
'css-loader'
]
},
{
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/,
use: [
'babel-loader',
'eslint-loader'
]
},
{
test: require.resolve('webextension-polyfill'),
use: 'imports-loader?browser=>undefined'
}
]
},
plugins: [
new HtmlPlugin({
template: 'template.html',
chunks: ['popup']
}),
new HtmlPlugin({
template: 'template.html',
chunks: ['app'],
title: 'Research Assistant',
filename: 'app.html'
}),
new WriteFilePlugin(),
IS_EXT ? new webpack.ProvidePlugin({
browser: 'webextension-polyfill'
}) : new Function(),
IS_EXT ? new WebpackShellPlugin({
onBuildStart:[`web-ext run --s ${dist}`]
}) : new Function(),
IS_PRODUCTION ? new MinifyPlugin() : /* no-op */ new Function()
],
devtool: IS_PRODUCTION ? '' : 'cheap-module-source-map'
}