forked from gallmarch/fl-conversion-helper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
82 lines (76 loc) · 1.94 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
const path = require('path');
const webpack = require('webpack');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const ExtractTextWebpackPlugin = require('extract-text-webpack-plugin');
const ZipPlugin = require('zip-webpack-plugin');
// We need this for a few things
const version = require(path.join(__dirname, 'package.json')).version; // eslint-disable-line import/no-dynamic-require
// Copy the manifest.json, inserting the current version as we go
const copy = new CopyWebpackPlugin([
// Copy popup menu HTML across
{
context: './src/',
from: 'popup/popup.html',
to: 'popup/popup.html',
},
// Copy manifest.json; replace version number
{
context: './src/',
from: 'manifest.json',
to: 'manifest.json',
transform: content => content.toString().replace('$VERSION', `${version}`),
},
// Copy app icons
{
context: './src/',
from : 'img',
to: 'img',
}
]);
// Define constants at build time
console.info(`NODE_ENV: ${process.env.NODE_ENV}`);
const defineConstants = new webpack.DefinePlugin({
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
});
const zip = new ZipPlugin({
path: path.join(__dirname, 'dist'),
filename: `fl-conversion-helper-${version}.zip`,
});
module.exports = {
entry: {
'content-script.js': './src/main.jsx',
'popup/popup.js': './src/popup/main.jsx',
'background.js': './src/background.js',
},
output: {
path: './build/',
filename: '[name]',
},
module: {
rules: [
{
test: /\.scss$/,
use: ExtractTextWebpackPlugin.extract({
use: ['css-loader', 'sass-loader'],
}),
},
{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader',
query: {
presets: ['@babel/react'],
},
},
],
},
plugins: [
copy,
defineConstants,
zip,
new ExtractTextWebpackPlugin('styles.css'),
],
resolve: {
extensions: ['.js', '.jsx'],
},
};