-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathwebpack.config.js
More file actions
91 lines (83 loc) · 2.43 KB
/
webpack.config.js
File metadata and controls
91 lines (83 loc) · 2.43 KB
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
86
87
88
89
90
91
let CopyWebpackPlugin = require('copy-webpack-plugin');
var ExtendedDefinePlugin = require('extended-define-webpack-plugin');
const TsConfigPathsPlugin = require('awesome-typescript-loader').TsConfigPathsPlugin;
const CleanWebpackPlugin = require('clean-webpack-plugin');
let _getParam = (name) => process.argv.find(p => p.startsWith(`--${name}=`)).split("=")[1];
let env = _getParam("env");
const config = {
amazon: {
environment: env,
tabUrlRegEx: /^http(s)?:\/\/music\.amazon\..+/,
showVolumeBar: false,
openPlayerUrl: "https://music.amazon.com",
reviewsUrl: "https://chrome.google.com/webstore/detail/amazon-web-app-playback/lnkimoaahjmlmbiafbfjdjdnmmoeecoo/reviews"
},
spotify: {
environment: env,
tabUrlRegEx: /^http(s)?:\/\/\w+\.spotify\.com.+/,
showVolumeBar: true,
openPlayerUrl: "https://open.spotify.com",
reviewsUrl: "https://chrome.google.com/webstore/detail/spotify-web-app-playback/goikghbjckploljhlfmjjfggccmlnbea/reviews"
}
}
module.exports = {
entry: {
popup: [
`./src/popup.ts`,
`./src/main.scss`
],
background: "./src/background.ts",
agent: `./src/${env}/agent.ts`
},
output: {
filename: "[name].js",
path: __dirname + `/dist/${env}`
},
devtool: "source-map",
resolve: {
extensions: [".ts", ".js", ".json"],
plugins: [
new TsConfigPathsPlugin()
]
},
module: {
rules: [
{ test: /\.ts$/, loader: "awesome-typescript-loader" },
{ enforce: "pre", test: /\.js$/, loader: "source-map-loader" },
{
test: /\.scss$/,
use: [
"style-loader", // creates style nodes from JS strings
"css-loader", // translates CSS into CommonJS
{
loader: "sass-loader", // compiles Sass to CSS, using Node Sass by default
options: {
includePaths: [`src/${env}`]
}
}
]
}
]
},
watchOptions: {
ignored: /node_modules/
},
externals: {
"chrome": "chrome"
},
plugins: [
new CleanWebpackPlugin([`dist/${env}`]),
new CopyWebpackPlugin([
{ from: "src/popup.html" },
// { from: `src/${env}/popup.css` },
{ from: "src/images", to: "images" },
{ from: `src/${env}/images`, to: "images" },
{ from: "src/lib", to: "lib" },
{ from: `src/${env}/manifest.json` },
{ from: `src/${env}/key.pem` }
]),
new ExtendedDefinePlugin({
__CONFIG__: config[env]
})
]
};