-
Notifications
You must be signed in to change notification settings - Fork 15
/
webpack.config.js
110 lines (105 loc) · 2.7 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
const CopyWebpackPlugin = require('copy-webpack-plugin');
const path = require('path');
const sass = require('sass');
const webpack = require('webpack');
const config = './js/popup/configuration-pages/';
let analytics,
development;
let setupAnalytics = function() {
switch (process.env.NODE_ENV) {
case 'production':
analytics = true;
development = false;
break;
case 'development':
analytics = false;
development = true;
break;
default:
analytics = false;
development = true;
break;
}
};
setupAnalytics();
module.exports = {
entry: {
'./js/popup/popup-logic/popup': './js/popup/popup-logic/popup.js',
// popup configs
[config + 'blocked-sellers']: `${config}blocked-sellers.js`,
[config + 'favorite-sellers']: `${config}favorite-sellers.js`,
[config + 'filter-shipping-country']: `${config}filter-shipping-country.js`,
[config + 'learn']: `${config}learn.js`,
[config + 'readability']: `${config}readability.js`,
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
},
mode: 'none',
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
loader: 'babel-loader',
},
{
test: /\.(png|jpg|gif|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192
}
}
]
},
{
test: /\.scss$/,
use: ['style-loader', 'css-loader', 'sass-loader']
}
]
},
plugins: [
new webpack.DefinePlugin({
__ANALYTICS__: analytics,
__DEV__: development
}),
// move all this stuff into the /dist folder
new CopyWebpackPlugin({
patterns: [
{ from: 'html', to: 'html' },
{ from: 'img', to: 'img' },
{ from: 'js/extension', to: 'js/extension' },
{ from: 'manifest.json', to: 'manifest.json' },
// CSS assets
{ from: 'css/dark-theme.scss', to: 'css/dark-theme.css',
transform(content, path) {
let result = sass.renderSync({ file: path });
return result.css.toString();
}
},
{ from: 'css/new-release-page-fixes.scss', to: 'css/new-release-page-fixes.css',
transform(content, path) {
let result = sass.renderSync({ file: path });
return result.css.toString();
}
},
{ from: 'css/compact-artist.scss', to: 'css/compact-artist.css',
transform(content, path) {
let result = sass.renderSync({ file: path });
return result.css.toString();
}
},
{
from: 'css',
to: 'css',
globOptions: {
ignore: ['**/*.scss']
}
}
]
}),
]
};