2019-02-21 16:43:45 +00:00
|
|
|
/* Copyright (c) 2018 Kamil Mikosz
|
|
|
|
* Copyright (c) 2019 Sienori
|
2019-02-20 08:10:03 +00:00
|
|
|
* Released under the MIT license.
|
|
|
|
* see https://opensource.org/licenses/MIT */
|
|
|
|
|
|
|
|
const {
|
|
|
|
getHTMLPlugins,
|
|
|
|
getOutput,
|
|
|
|
getCopyPlugins,
|
|
|
|
getFirefoxCopyPlugins,
|
|
|
|
getEntry
|
|
|
|
} = require("./webpack.utils");
|
|
|
|
const path = require("path");
|
|
|
|
const config = require("./config.json");
|
2019-03-23 06:58:42 +00:00
|
|
|
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
2019-02-20 08:10:03 +00:00
|
|
|
|
|
|
|
const generalConfig = {
|
|
|
|
mode: "development",
|
|
|
|
devtool: "source-map",
|
|
|
|
resolve: {
|
|
|
|
alias: {
|
2019-03-21 10:38:08 +00:00
|
|
|
src: path.resolve(__dirname, "src/"),
|
|
|
|
"webextension-polyfill": "webextension-polyfill/dist/browser-polyfill.min.js"
|
2019-02-20 08:10:03 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
module: {
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
loader: "babel-loader",
|
|
|
|
exclude: /node_modules/,
|
|
|
|
test: /\.(js|jsx)$/,
|
|
|
|
resolve: {
|
|
|
|
extensions: [".js", ".jsx"]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
2019-05-02 14:31:11 +00:00
|
|
|
test: /\.(scss|css)$/,
|
2019-03-23 06:58:42 +00:00
|
|
|
exclude: [path.resolve(__dirname, "src", "content")],
|
2019-02-20 08:10:03 +00:00
|
|
|
use: [
|
|
|
|
{
|
|
|
|
loader: "style-loader"
|
|
|
|
},
|
|
|
|
{
|
2021-05-16 12:03:33 +00:00
|
|
|
loader: "css-loader",
|
|
|
|
options: {
|
|
|
|
esModule: false
|
|
|
|
}
|
2019-02-20 08:10:03 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: "sass-loader"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2019-03-23 06:58:42 +00:00
|
|
|
{
|
2019-05-02 14:31:11 +00:00
|
|
|
test: /\.(scss|css)$/,
|
2019-03-23 06:58:42 +00:00
|
|
|
include: [path.resolve(__dirname, "src", "content")],
|
|
|
|
use: [
|
|
|
|
MiniCssExtractPlugin.loader,
|
|
|
|
{
|
2021-05-16 12:03:33 +00:00
|
|
|
loader: "css-loader",
|
|
|
|
options: {
|
|
|
|
esModule: false
|
|
|
|
}
|
2019-03-23 06:58:42 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
loader: "sass-loader"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2019-02-20 08:10:03 +00:00
|
|
|
{
|
|
|
|
test: /\.svg$/,
|
|
|
|
use: [
|
|
|
|
"babel-loader",
|
|
|
|
{
|
|
|
|
loader: "react-svg-loader",
|
|
|
|
options: {
|
|
|
|
svgo: {
|
|
|
|
plugins: [{ removeTitle: false }],
|
|
|
|
floatPrecision: 2
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
2019-03-21 10:41:28 +00:00
|
|
|
const BundleAnalyzerPlugin = require("webpack-bundle-analyzer").BundleAnalyzerPlugin;
|
2019-02-20 08:10:03 +00:00
|
|
|
module.exports = [
|
|
|
|
{
|
|
|
|
...generalConfig,
|
|
|
|
entry: getEntry(config.chromePath),
|
|
|
|
output: getOutput("chrome", config.devDirectory),
|
|
|
|
plugins: [
|
2019-03-23 06:58:42 +00:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: "[name]/[name].css"
|
|
|
|
}),
|
2019-02-20 08:10:03 +00:00
|
|
|
...getHTMLPlugins("chrome", config.devDirectory, config.chromePath),
|
|
|
|
...getCopyPlugins("chrome", config.devDirectory, config.chromePath)
|
|
|
|
]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
...generalConfig,
|
|
|
|
entry: getEntry(config.firefoxPath),
|
|
|
|
output: getOutput("firefox", config.devDirectory),
|
|
|
|
plugins: [
|
2019-03-23 06:58:42 +00:00
|
|
|
new MiniCssExtractPlugin({
|
|
|
|
filename: "[name]/[name].css"
|
|
|
|
}),
|
2019-02-20 08:10:03 +00:00
|
|
|
...getFirefoxCopyPlugins("firefox", config.devDirectory, config.firefoxPath),
|
2019-03-21 10:41:28 +00:00
|
|
|
...getHTMLPlugins("firefox", config.devDirectory, config.firefoxPath),
|
|
|
|
new BundleAnalyzerPlugin({
|
|
|
|
openAnalyzer: false,
|
|
|
|
analyzerHost: "127.0.0.1",
|
|
|
|
analyzerPort: 8888
|
|
|
|
})
|
2019-02-20 08:10:03 +00:00
|
|
|
]
|
|
|
|
}
|
|
|
|
];
|