add full support for webpack + css

This commit is contained in:
Seth Burkart
2023-08-13 19:07:24 +10:00
parent 08ce9c2525
commit 08f0c16a6c
6 changed files with 41 additions and 6 deletions
+3
View File
@@ -14,6 +14,9 @@
"copy-webpack-plugin": "^11.0.0", "copy-webpack-plugin": "^11.0.0",
"css-loader": "^6.8.1", "css-loader": "^6.8.1",
"file-loader": "^6.2.0", "file-loader": "^6.2.0",
"mini-css-extract-plugin": "^2.7.6",
"sass": "^1.65.1",
"sass-loader": "^13.3.2",
"style-loader": "^3.3.3", "style-loader": "^3.3.3",
"webpack": "^5.88.2", "webpack": "^5.88.2",
"webpack-cli": "^5.1.4" "webpack-cli": "^5.1.4"
+1
View File
@@ -0,0 +1 @@
import './documentload.css';
+1
View File
@@ -0,0 +1 @@
import './iframe.css';
+14 -1
View File
@@ -8,6 +8,19 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. */
@import url('https://fonts.googleapis.com/css?family=Rubik:300,400,500,600');
/* // This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>. */ // along with this program. If not, see <https://www.gnu.org/licenses/>. */
@import url('https://fonts.googleapis.com/css?family=Rubik:300,400,500,600'); @import url('https://fonts.googleapis.com/css?family=Rubik:300,400,500,600');
@@ -1243,7 +1256,7 @@ body {
content: ""; content: "";
width: 14px; width: 14px;
height: 12px; height: 12px;
background-image: url(/icons/betterseqta-light-outline.png); background-image: url("../../public/icons/betterseqta-light-outline.png");
display: inline-block; display: inline-block;
background-size: 18px 18px; background-size: 18px 18px;
color: #fff; color: #fff;
+1
View File
@@ -0,0 +1 @@
import './injected.css';
+21 -5
View File
@@ -1,26 +1,36 @@
const path = require('path'); const path = require('path');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin');
module.exports = { module.exports = {
performance: { performance: {
hints: false, hints: false,
maxEntrypointSize: 512000, maxEntrypointSize: 512000,
maxAssetSize: 512000 maxAssetSize: 512000,
}, },
devtool: 'cheap-module-source-map', devtool: 'cheap-module-source-map',
entry: { entry: {
'SEQTA': './src/SEQTA.js', 'SEQTA': './src/SEQTA.js',
'background': './src/background.js', 'background': './src/background.js',
'inject-documentload': './src/inject/documentload.css', // Entry for CSS
'inject-iframe': './src/inject/iframe.css', // Entry for CSS
'inject-injected': './src/inject/injected.css', // Entry for CSS
}, },
output: { output: {
filename: '[name].js', filename: (pathData) => {
const name = pathData.chunk.name.replace('inject-', '');
return name.includes('inject') ? `inject/${name}.js` : `${name}.js`;
},
path: path.resolve(__dirname, 'build'), path: path.resolve(__dirname, 'build'),
}, },
module: { module: {
rules: [ rules: [
{ {
test: /\.css$/, test: /\.css$/,
use: ['style-loader', 'css-loader'], use: [
MiniCssExtractPlugin.loader,
'css-loader',
],
include: path.resolve(__dirname, 'src'), include: path.resolve(__dirname, 'src'),
}, },
{ {
@@ -33,10 +43,16 @@ module.exports = {
], ],
}, },
plugins: [ plugins: [
new MiniCssExtractPlugin({
filename: (pathData) => {
const name = pathData.chunk.name.replace('inject-', '');
return name.includes('inject') ? `inject/${name}.css` : `inject/${name}.css`;
},
}),
new CopyWebpackPlugin({ new CopyWebpackPlugin({
patterns: [ patterns: [
{ from: 'public', to: '.' }, // Copies everything from the public folder to the root level of build { from: 'public', to: '.' },
{ from: 'src/inject', to: 'inject' }, { from: 'src/inject/preview', to: 'inject/preview' },
], ],
}), }),
], ],