-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
83 lines (75 loc) · 2.1 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
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const webpack = require('webpack');
var path = require('path');
const Package = require('./package');
var developmentPath = path.resolve(__dirname, 'buid/dev');
var productionChromePath = path.resolve(__dirname, 'buid/chrome');
var productionMozPath = path.resolve(__dirname, 'buid/moz');
var buildPath = process.env.NODE_ENV === undefined ? developmentPath : process.env.NODE_ENV === "chrome" ? productionChromePath : productionMozPath;
var browserType = process.env.NODE_ENV === "moz" ? "browser" : "chrome";
var browserConfig = process.env.NODE_ENV === "moz" ? "./app/browser/moz/manifest.json" : "./app/browser/chrome/manifest.json";
module.exports = (env, argv) => {
return {
mode: argv.mode === undefined ? 'development' : 'production',
entry: {
logic: './app/assets/js/main.js',
popup: './app/interface/js/popup.js',
content: './app/assets/js/content/content.js'
},
output: {
filename: 'js/[name].bundle.js',
sourceMapFilename: 'sourceMap/[name].map',
path: buildPath
},
devtool: 'source-map',
module: {
rules: [{
test: /\.(png|jpg)$/,
loader: 'url-loader',
}, {
test: /\.scss$/,
use: [
"style-loader",
"css-loader",
"sass-loader"
]
}]
},
plugins: [
new webpack.DefinePlugin({
WEBPACK_BROWSER_TYPE: JSON.stringify(browserType)
}),
new CopyWebpackPlugin([
browserConfig,
{
from: './app/assets/images/',
to: 'images',
toType: 'dir',
flatten: false
},
{
from: './node_modules/jsstore/dist/jsstore.worker.min.js',
to: 'vendor',
toType: 'dir',
flatten: false
}
]),
new HtmlWebpackPlugin({
filename: 'popup.html',
title: 'Project Tabber',
template: './app/interface/popup.html',
chunks: ['popup'],
hash: true,
minify: {
collapseWhitespace: true,
removeComments: true,
removeRedundantAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true,
useShortDoctype: true
}
})
]
}
};