chore: fix clipper CI failing

This commit is contained in:
Aman Harwara
2023-07-12 19:42:45 +05:30
parent e4b858f2e8
commit af3eafb009
31 changed files with 275 additions and 39 deletions

View File

@@ -4,7 +4,7 @@
"description": "Web clipper for Standard Notes",
"permissions": ["activeTab", "storage", "<all_urls>"],
"browser_action": {
"default_popup": "popup/index.html?route=extension"
"default_popup": "popup.html?route=extension"
},
"background": {
"scripts": ["background.js"],

View File

@@ -4,7 +4,7 @@
"description": "Web clipper for Standard Notes",
"permissions": ["activeTab", "storage"],
"action": {
"default_popup": "popup/index.html?route=extension"
"default_popup": "popup.html?route=extension"
},
"background": {
"service_worker": "background.js"

View File

@@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
<meta content="viewport-fit=cover, width=device-width, initial-scale=1" name="viewport" />
<meta name="theme-color" content="#ffffff" />
<title>Standard Notes</title>
<script src="./globals.js"></script>
<script src="../web/app.js" debug="false"></script>
<link rel="stylesheet" media="all" href="../web/app.css" debug="false" />
<style>
html,
body {
min-width: 350px;
max-width: 350px;
}
</style>
</head>
<body></body>
</html>

View File

@@ -17,9 +17,9 @@ module.exports = (env, argv) => {
patterns: [
{
from: '../web/dist',
to: './web',
to: './',
globOptions: {
ignore: isProd ? ['**/app.js.map'] : [],
ignore: isProd ? ['**/*.js.map'] : [],
},
},
{
@@ -36,7 +36,7 @@ module.exports = (env, argv) => {
},
{
from: './src/popup',
to: './popup',
to: './',
},
{
from: './images',

View File

@@ -102,9 +102,9 @@ export class RouteParser implements RouteParserInterface {
return RouteType.Onboarding
}
const isIndexPath = this.path.endsWith('index.html')
const isValidPath = ['index.html', 'popup.html'].some((path) => this.path.endsWith(path))
if (this.path !== RootRoutes.None && !isIndexPath) {
if (this.path !== RootRoutes.None && !isValidPath) {
return RouteType.None
}

View File

@@ -0,0 +1,23 @@
module.exports = ({ htmlWebpackPlugin }) => {
return `<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta content="IE=edge" http-equiv="X-UA-Compatible" />
<meta content="viewport-fit=cover, width=device-width, initial-scale=1" name="viewport" />
<meta name="theme-color" content="#ffffff" />
<title>Standard Notes</title>
<script src="./globals.js"></script>
${htmlWebpackPlugin.tags.headTags}
<style>
html,
body {
min-width: 350px;
max-width: 350px;
min-height: 260px;
}
</style>
</head>
<body></body>
</html>`
}

View File

@@ -72,6 +72,7 @@
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-react": "^7.31.11",
"eslint-plugin-react-hooks": "^4.6.0",
"html-webpack-plugin": "^5.5.3",
"identity-obj-proxy": "^3.0.0",
"jest": "^29.3.1",
"jest-environment-jsdom": "^29.3.1",

View File

@@ -4,6 +4,8 @@ const MiniCssExtractPlugin = require('mini-css-extract-plugin')
const CircularDependencyPlugin = require('circular-dependency-plugin')
const CopyWebpackPlugin = require('copy-webpack-plugin')
const mergeWithEnvDefaults = require('./web.webpack-defaults')
const HtmlWebpackPlugin = require('html-webpack-plugin')
const clipperHtmlTemplate = require('./clipper.htmlTemplate')
require('dotenv').config()
module.exports = (env) => {
@@ -28,8 +30,16 @@ module.exports = (env) => {
return {
entry: './src/javascripts/index.ts',
output: {
filename: './app.js',
filename: process.env.BUILD_TARGET === 'clipper' ? './[name].bundle.js' : './app.js',
},
optimization:
process.env.BUILD_TARGET === 'clipper'
? {
splitChunks: {
chunks: 'all',
},
}
: undefined,
plugins: [
new CircularDependencyPlugin({
// exclude detection of files based on a RegExp
@@ -55,6 +65,12 @@ module.exports = (env) => {
new CopyWebpackPlugin({
patterns: copyPluginPatterns,
}),
process.env.BUILD_TARGET === 'clipper' &&
new HtmlWebpackPlugin({
filename: 'popup.html',
inject: false,
templateContent: clipperHtmlTemplate,
}),
],
resolve: {
extensions: ['.ts', '.tsx', '.js'],