Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
- uses: actions/setup-node@v4
with:
node-version: 20
node-version-file: ui/.nvmrc
cache: npm
cache-dependency-path: ui/package-lock.json
- id: get_version
run: |
RELEASE_VERSION=$(echo $GITHUB_REF | sed -nE 's!refs/tags/!!p')
echo "::set-output name=release_version::$RELEASE_VERSION"
- name: Cache node modules
uses: actions/cache@v4
with:
path: ui/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/ui/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Build UI
env:
VERSION: ${{ steps.get_version.outputs.release_version }}
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@ jobs:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 20
- name: Cache node modules
uses: actions/cache@v4
with:
path: ui/node_modules
key: ${{ runner.os }}-node-${{ hashFiles('**/ui/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
node-version-file: ui/.nvmrc
cache: npm
cache-dependency-path: ui/package-lock.json
- name: Build UI
env:
CI: "false"
Expand Down
17 changes: 15 additions & 2 deletions hack/build-all.bash
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,12 @@ COMPONENT_CHART_VERSION=$(cat pkg/devspace/deploy/deployer/helm/client.go | grep

# Move ui.tar.gz to releases
echo "Moving ui"
mv ui.tar.gz "${DEVSPACE_ROOT}/release/ui.tar.gz"
if [[ -f "${DEVSPACE_ROOT}/ui.tar.gz" ]]; then
mv "${DEVSPACE_ROOT}/ui.tar.gz" "${DEVSPACE_ROOT}/release/ui.tar.gz"
elif [[ ! -f "${DEVSPACE_ROOT}/release/ui.tar.gz" ]]; then
echo "ui tarball not found; run ./hack/build-ui.bash first" 1>&2
exit 1
fi
shasum -a 256 "${DEVSPACE_ROOT}/release/ui.tar.gz" > "${DEVSPACE_ROOT}/release/ui.tar.gz".sha256

# build devspace helper
Expand All @@ -85,7 +90,15 @@ GOARCH=arm64 GOOS=linux go build -ldflags "-s -w -X github.com/loft-sh/devspace/
shasum -a 256 "${DEVSPACE_ROOT}/release/devspacehelper-arm64" > "${DEVSPACE_ROOT}/release/devspacehelper-arm64".sha256

# build bin data
$GOPATH/bin/go-bindata -o assets/assets.go -pkg assets release/devspacehelper release/ui.tar.gz component-chart-$COMPONENT_CHART_VERSION.tgz
GO_BINDATA="$(command -v go-bindata || true)"
if [[ -z "${GO_BINDATA}" ]]; then
GO_BINDATA="$(go env GOPATH)/bin/go-bindata"
fi
if [[ ! -x "${GO_BINDATA}" ]]; then
echo "go-bindata not found; install it with: go install github.com/go-bindata/go-bindata/go-bindata@latest" 1>&2
exit 1
fi
"${GO_BINDATA}" -o assets/assets.go -pkg assets release/devspacehelper release/ui.tar.gz component-chart-$COMPONENT_CHART_VERSION.tgz

for OS in ${DEVSPACE_BUILD_PLATFORMS[@]}; do
for ARCH in ${DEVSPACE_BUILD_ARCHS[@]}; do
Expand Down
2 changes: 1 addition & 1 deletion hack/build-ui.bash
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -e
DEVSPACE_ROOT=$(git rev-parse --show-toplevel)

# Install dependencies
cd ui && npm install && npm run build
cd ui && npm ci && npm run build

# Pack ui
echo "Packing ui"
Expand Down
1 change: 1 addition & 0 deletions ui/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24
24 changes: 24 additions & 0 deletions ui/config/HtmlInterpolatePlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
'use strict';

class HtmlInterpolatePlugin {
constructor(replacements) {
this.replacements = replacements;
}

apply(compiler) {
compiler.hooks.compilation.tap('HtmlInterpolatePlugin', compilation => {
const HtmlWebpackPlugin = require('html-webpack-plugin');
const hooks = HtmlWebpackPlugin.getHooks(compilation);

hooks.beforeEmit.tap('HtmlInterpolatePlugin', data => {
data.html = Object.keys(this.replacements).reduce(
(html, key) => html.replace(new RegExp(`%${key}%`, 'g'), this.replacements[key]),
data.html
);
return data;
});
});
}
}

module.exports = HtmlInterpolatePlugin;
14 changes: 0 additions & 14 deletions ui/config/jest/cssTransform.js

This file was deleted.

12 changes: 0 additions & 12 deletions ui/config/jest/fileTransform.js

This file was deleted.

26 changes: 0 additions & 26 deletions ui/config/jest/typescriptTransform.js

This file was deleted.

1 change: 0 additions & 1 deletion ui/config/paths.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ module.exports = {
appNodeModules: resolveApp('node_modules'),
appTsConfig: resolveApp('tsconfig.json'),
appTsProdConfig: resolveApp('tsconfig.prod.json'),
appTsLint: resolveApp('tslint.json'),
publicUrl: getPublicUrl(resolveApp('package.json')),
servedPath: getServedPath(resolveApp('package.json')),
};
22 changes: 2 additions & 20 deletions ui/config/polyfills.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
'use strict';

if (typeof Promise === 'undefined') {
// Rejection tracking prevents a common issue where React gets into an
// inconsistent state due to an error, but it gets swallowed by a Promise,
// and the user has no idea what causes React's erratic future behavior.
require('promise/lib/rejection-tracking').enable();
window.Promise = require('promise/lib/es6-extensions.js');
}

// fetch() polyfill for making API calls.
require('whatwg-fetch');

// Object.assign() is commonly used with React.
// It will use the native implementation if it's present and isn't buggy.
Object.assign = require('object-assign');

// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet.
// We don't polyfill it in the browser--this is user's responsibility.
if (process.env.NODE_ENV === 'test') {
require('raf').polyfill(global);
}
// Modern browser and Node targets provide the platform APIs previously
// polyfilled here.
99 changes: 28 additions & 71 deletions ui/config/webpack.config.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ const autoprefixer = require('autoprefixer');
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
const ESLintWebpackPlugin = require('eslint-webpack-plugin');
const getClientEnvironment = require('./env');
const paths = require('./paths');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
const HtmlInterpolatePlugin = require('./HtmlInterpolatePlugin');

// Webpack uses `publicPath` to determine where the app is being served from.
// In development, we always serve from the root. This makes config easier.
Expand Down Expand Up @@ -39,26 +38,11 @@ module.exports = {
mode: 'development',
// These are the "entry points" to our application.
// This means they will be the "root" imports that are included in JS bundle.
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
entry: [
// We ship a few polyfills by default:
require.resolve('./polyfills'),
// Include an alternative client for WebpackDevServer. A client's job is to
// connect to WebpackDevServer by a socket and get notified about changes.
// When you save a file, the client will either apply hot updates (in case
// of CSS changes), or refresh the page (in case of JS changes). When you
// make a syntax error, this client will display a syntax error overlay.
// Note: instead of the default WebpackDevServer client, we use a custom one
// to bring better experience for Create React App users. You can replace
// the line below with these two lines if you prefer the stock client:
// require.resolve('webpack-dev-server/client') + '?/',
// require.resolve('webpack/hot/dev-server'),
require.resolve('react-dev-utils/webpackHotDevClient'),
// Finally, this is your app's code:
paths.appIndexJs,
// We include the app code last so that if there is a runtime error during
// initialization, it doesn't blow up the WebpackDevServer client, and
// changing JS code would still trigger a refresh.
],
output: {
// Add /* filename */ comments to generated require()s in the output.
Expand All @@ -75,6 +59,13 @@ module.exports = {
devtoolModuleFilenameTemplate: (info) => path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
},
resolve: {
fallback: {
dgram: false,
fs: false,
net: false,
tls: false,
child_process: false,
},
// This allows you to set a fallback for where Webpack should look for modules.
// We placed these paths second because we want `node_modules` to "win"
// if there are any conflicts. This matches Node resolution mechanism.
Expand All @@ -95,20 +86,7 @@ module.exports = {
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
'react-native': 'react-native-web',
},
fallback: {
dgram: false,
fs: false,
net: false,
tls: false,
child_process: false,
},
plugins: [
// Prevents users from importing files from outside of src/ (or node_modules/).
// This often causes confusion because we only process files within src/ with babel.
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
// please link the files into your node_modules/ and let module-resolution kick in.
// Make sure your source files are compiled, as they will not be processed in any way.
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
new TsconfigPathsPlugin({ configFile: paths.appTsConfig }),
],
},
Expand All @@ -129,23 +107,18 @@ module.exports = {
// match the requirements. When no loader matches it will fall
// back to the "file" loader at the end of the loader list.
oneOf: [
// "url" loader works like "file" loader except that it embeds assets
// smaller than specified limit in bytes as data URLs to avoid requests.
// Inline small assets and emit larger ones via Webpack 5 asset modules.
// A missing `test` is equivalent to a match.
{
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/, /\.svg$/],
loader: require.resolve('url-loader'),
options: {
limit: 10000, // Convert images < 8kb to base64 strings
name: 'src/images/[name].[hash:8].[ext]',
type: 'asset',
parser: {
dataUrlCondition: {
maxSize: 10000,
},
},
},
{
test: /\.(js|jsx|mjs)$/,
include: paths.appSrc,
loader: require.resolve('babel-loader'),
options: {
compact: true,
generator: {
filename: 'src/images/[name].[hash:8][ext]',
},
},
// Compile .tsx?
Expand All @@ -170,6 +143,7 @@ module.exports = {
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
esModule: false,
modules: {
localIdentName: '[path][name]__[local]',
},
Expand Down Expand Up @@ -205,6 +179,7 @@ module.exports = {
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
esModule: false,
},
},
{
Expand All @@ -216,12 +191,6 @@ module.exports = {
plugins: [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 9', // React doesn't support IE8 anyway
],
flexbox: 'no-2009',
}),
],
Expand Down Expand Up @@ -260,33 +229,21 @@ module.exports = {
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
// In development, this will be an empty string.
new InterpolateHtmlPlugin(HtmlWebpackPlugin, env.raw),
// Add module names to factory functions so they appear in browser profiler.
new webpack.NamedModulesPlugin(),
new HtmlInterpolatePlugin(env.raw),
// Makes some environment variables available to the JS code, for example:
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
new webpack.DefinePlugin(env.stringified),
// This is necessary to emit hot updates (currently CSS only):
new webpack.HotModuleReplacementPlugin(),
// Watcher doesn't work well if you mistype casing in a path so we use
// a plugin that prints an error when you attempt to do this.
// See https://github.com/facebookincubator/create-react-app/issues/240
new CaseSensitivePathsPlugin(),
// Moment.js is an extremely popular library that bundles large locale files
// by default due to how Webpack interprets its code. This is a practical
// solution that requires the user to opt into importing specific locales.
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
// You can remove this if you don't use Moment.js:
new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/,
}),
// Perform type checking and linting in a separate process to speed up compilation
new ForkTsCheckerWebpackPlugin({
async: false,
watch: paths.appSrc,
tsconfig: paths.appTsConfig,
tslint: paths.appTsLint,
typescript: {
configFile: paths.appTsConfig,
},
}),
new ESLintWebpackPlugin({
context: path.dirname(paths.appPackageJson),
extensions: ['js', 'jsx', 'ts', 'tsx'],
files: 'src/**/*.{js,jsx,ts,tsx}',
}),
],
// Turn off performance hints during development because we don't do any
Expand Down
Loading