Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"license": "GPL-3.0",
"private": true,
"scripts": {
"build": "NODE_OPTIONS=\"--max-old-space-size=4096\" yarn build:deps && yarn build:prod",
"build:prod": "NODE_OPTIONS=\"--max-old-space-size=4096\" lerna run build --scope homepage --stream && lerna run build --scope app --stream && gulp",
"build": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" yarn build:deps && yarn build:prod",
"build:prod": "cross-env NODE_OPTIONS=\"--max-old-space-size=4096\" lerna run build --scope homepage --stream && lerna run build --scope app --stream && lerna run copy-assets --scope app --stream",
"build:embed": "lerna run build:embed --scope app --stream && gulp",
"build:clean": "lerna run build:clean --scope app --scope homepage && rimraf www",
"build:deps": "lerna run build:dev --scope codesandbox-api --scope @codesandbox/notifications && lerna run build:dev --scope @codesandbox/common && lerna run build:dev --scope vscode-textmate --scope codesandbox-browserfs --scope node-services && lerna run build:dev --scope sse-hooks",
Expand All @@ -14,7 +14,7 @@
"start": "yarn build:deps && lerna run start --scope app --stream",
"start:overmind": "yarn build:deps && concurrently \"lerna run start --scope app --stream\" \"overmind-devtools\"",
"start:fast": "lerna run start --scope app --stream",
"start:vscode": "VSCODE=1 yarn start:fast & cd standalone-packages/monaco-editor && yarn simpleserver & cd standalone-packages/vscode && yarn watch",
"start:vscode": "cross-env VSCODE=1 yarn start:fast & cd standalone-packages/monaco-editor && yarn simpleserver & cd standalone-packages/vscode && yarn watch",
"start:dynamic": "lerna run dev --scope dynamic-pages --stream",
"start:common": "lerna run start --scope common --stream",
"start:home": "lerna run start --scope homepage --stream",
Expand Down
4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"build:embed": "cross-env NODE_ENV=production webpack --config config/webpack.embed.js",
"build:sandbox": "cross-env NODE_ENV=production SANDBOX_ONLY=true node scripts/build.js",
"build:clean": "rimraf www",
"copy-assets": "cross-env NODE_ENV=production node scripts/copy-assets.js",
"test": "jest --env=jsdom",
"test:watch": "jest --watch --env=jsdom",
"test:integrations": "jest --config integration-tests/jest.config.json --maxWorkers=2",
Expand Down Expand Up @@ -65,7 +66,6 @@
"babel-preset-env": "^1.6.0",
"babel-preset-react": "^6.24.1",
"buffer-loader": "^0.0.1",
"cache-loader": "^2.0.1",
"case-sensitive-paths-webpack-plugin": "^2.0.0",
"chalk": "1.1.3",
"connect-history-api-fallback": "1.3.0",
Expand All @@ -78,7 +78,7 @@
"file-loader": "^1.1.11",
"filesize": "^3.5.6",
"flow-bin": "^0.57.3",
"fs-extra": "^2.1.2",
"fs-extra": "^8.0.1",
"gulp-replace": "^0.5.4",
"gzip-size": "3.0.0",
"html-loader": "^0.5.5",
Expand Down
24 changes: 18 additions & 6 deletions packages/app/scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,10 @@ function build(previousSizeMap) {
} build...`
);
let compiler = webpack(config);
const start = Date.now();
compiler.run((err, stats) => {
if (err) {
console.error('Failed to create a production build. Reason:');
console.error('Error creating a production build:');
console.error(err.message || err);
console.error(err.stack);
process.exit(1);
Expand All @@ -130,17 +131,28 @@ function build(previousSizeMap) {
const info = stats.toJson();

if (stats.hasErrors()) {
console.error('Failed to create a production build. Reason:');
console.error('Error creating a production build:');
console.error(info.errors);
ls - a;
process.exit(1);
}

if (stats.hasWarnings()) {
console.warn('Warnings in Webpack build:');
console.warn(info.warnings);
console.warn(chalk.yellow('Build warnings:'));
// console.warn(info.warnings);
stats.compilation.warnings.forEach(({ name, message }) => {
console.warn(chalk.yellow(`${name}: ${message}\n`));
});
}

console.log(chalk.green('Compiled successfully.'));
const took = Date.now() - start;

console.log(
chalk.green(
`Built ${stats.hasWarnings() ? 'with warnings ' : ''}in ${took /
1000}s.`
)
);
console.log();

// console.log('File sizes after gzip:');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can start showing this again after we remove CopyWebpackPlugin, I commented this because it was also showing all files copied by the plugin (+50,000 files), which made the build actually slow because of slow stdout.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can / should do something more involved as a separate step in the build process.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, like a check? I'd agree with that, if you can include it in this PR that would be nice, if not we could uncomment this for now in the meantime.

Copy link
Contributor Author

@lbogdan lbogdan Jun 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But how does that work, anyway, as in CI we don't have the previous build's assets?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do! We cache them between builds in CircleCI.

Expand Down Expand Up @@ -240,7 +252,7 @@ function build(previousSizeMap) {
);
console.log();
}
console.log(`The ${chalk.cyan('build')} folder is ready to be deployed.`);
console.log(`The ${chalk.cyan('www')} folder is ready to be deployed.`);
console.log('You may also serve it locally with a static server:');
console.log();
console.log(` ${chalk.cyan('npm')} install -g pushstate-server`);
Expand Down
78 changes: 78 additions & 0 deletions packages/app/scripts/copy-assets.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const fs = require('fs-extra');
const path = require('path');

const __DEV__ = process.env.NODE_ENV === 'development';

const assets = [
{
from: 'packages/app/www',
to: '',
},
{
from: 'packages/homepage/public',
to: '',
},
{
from: 'standalone-packages/monaco-editor/release/min/vs',
to: 'public/14/vs',
},
{
from: 'standalone-packages/codesandbox-browserfs/dist',
to: 'static/browserfs2',
},
{
from: 'standalone-packages/vscode-editor/release/min/vs',
to: 'public/vscode8',
},
{
from: 'packages/app/public',
to: '',
},

// ex-copy-webpack-plugin
{
from: 'standalone-packages/vscode-editor/release/min/vs',
to: 'public/vscode22/vs',
},
{
from: 'standalone-packages/vscode-extensions/out',
to: 'public/vscode-extensions/v8',
},
{
from: 'node_modules/onigasm/lib/onigasm.wasm',
to: 'public/onigasm/2.2.1/onigasm.wasm',
},
{
from:
'standalone-packages/vscode-textmate/node_modules/onigasm/lib/onigasm.wasm',
to: 'public/onigasm/2.1.0/onigasm.wasm',
},
{
from: 'node_modules/monaco-vue/release/min',
to: 'public/14/vs/language/vue',
},
{
from: 'standalone-packages/monaco-editor/release/min/vs',
to: 'public/14/vs',
},
{
from: 'packages/app/static',
to: 'static',
},
{
from: __DEV__
? 'standalone-packages/codesandbox-browserfs/build'
: 'standalone-packages/codesandbox-browserfs/dist',
to: 'static/browserfs3',
},
];

const rootPath = path.resolve(__dirname, '../../..');
const buildPath = path.resolve(rootPath, 'www');

assets.forEach(({ from, to }) => {
const srcPath = path.resolve(rootPath, from);
const dstPath = path.resolve(buildPath, to);
console.log(`${srcPath} => ${dstPath}`);
fs.copySync(srcPath, dstPath);
});
4 changes: 0 additions & 4 deletions packages/app/scripts/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ function addMiddleware(devServer, index) {
from: '../../standalone-packages/monaco-editor/release/min/vs',
to: 'public/14/vs',
},
{
from: '../sse-hooks/dist',
to: 'public/sse-hooks',
},
{
from: 'static',
to: 'static',
Expand Down
27 changes: 9 additions & 18 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6105,17 +6105,6 @@ cache-base@^1.0.1:
union-value "^1.0.0"
unset-value "^1.0.0"

cache-loader@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/cache-loader/-/cache-loader-2.0.1.tgz#5758f41a62d7c23941e3c3c7016e6faeb03acb07"
integrity sha512-V99T3FOynmGx26Zom+JrVBytLBsmUCzVG2/4NnUKgvXN4bEV42R1ERl1IyiH/cvFIDA1Ytq2lPZ9tXDSahcQpQ==
dependencies:
loader-utils "^1.1.0"
mkdirp "^0.5.1"
neo-async "^2.6.0"
normalize-path "^3.0.0"
schema-utils "^1.0.0"

cache-manager-fs-hash@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/cache-manager-fs-hash/-/cache-manager-fs-hash-0.0.6.tgz#fccc5a6b579080cbe2186697e51b5b8ff8ca9fd0"
Expand Down Expand Up @@ -10644,13 +10633,6 @@ fs-extra@^1.0.0:
jsonfile "^2.1.0"
klaw "^1.0.0"

fs-extra@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-2.1.2.tgz#046c70163cef9aad46b0e4a7fa467fb22d71de35"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"

fs-extra@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291"
Expand Down Expand Up @@ -10684,6 +10666,15 @@ fs-extra@^7.0.1:
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-extra@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-8.0.1.tgz#90294081f978b1f182f347a440a209154344285b"
integrity sha512-W+XLrggcDzlle47X/XnS7FXrXu9sDo+Ze9zpndeBxdgv88FHLm1HtmkhEwavruS6koanBjp098rUpHs65EmG7A==
dependencies:
graceful-fs "^4.1.2"
jsonfile "^4.0.0"
universalify "^0.1.0"

fs-minipass@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
Expand Down