Skip to content

Commit aae7022

Browse files
author
Ives van Hoorne
committed
Cleanup
1 parent e7398f7 commit aae7022

File tree

3 files changed

+132
-228
lines changed

3 files changed

+132
-228
lines changed

packages/app/config/webpack.common.js

Lines changed: 108 additions & 77 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@ module.exports = {
6060
],
6161
},
6262
target: 'web',
63+
6364
node: {
6465
process: false,
6566
Buffer: false,
6667
setImmediate: false,
6768
module: 'empty',
6869
child_process: 'empty',
6970
},
71+
7072
output: {
7173
path: paths.appBuild,
7274
pathinfo: true,
@@ -249,61 +251,84 @@ module.exports = {
249251
},
250252
],
251253
}),
252-
// Generates an `index.html` file with the <script> injected.
253-
new HtmlWebpackPlugin({
254-
inject: true,
255-
chunks: ['common-sandbox', 'common', 'app'],
256-
filename: 'app.html',
257-
template: paths.appHtml,
258-
minify: __PROD__ && {
259-
removeComments: false,
260-
collapseWhitespace: true,
261-
removeRedundantAttributes: true,
262-
useShortDoctype: true,
263-
removeEmptyAttributes: true,
264-
removeStyleLinkTypeAttributes: true,
265-
keepClosingSlash: true,
266-
minifyJS: true,
267-
minifyCSS: true,
268-
minifyURLs: true,
269-
},
270-
}),
271-
new HtmlWebpackPlugin({
272-
inject: true,
273-
chunks: ['sandbox-startup', 'common-sandbox', 'sandbox'],
274-
filename: 'frame.html',
275-
template: paths.sandboxHtml,
276-
minify: __PROD__ && {
277-
removeComments: true,
278-
collapseWhitespace: true,
279-
removeRedundantAttributes: true,
280-
useShortDoctype: true,
281-
removeEmptyAttributes: true,
282-
removeStyleLinkTypeAttributes: true,
283-
keepClosingSlash: true,
284-
minifyJS: true,
285-
minifyCSS: true,
286-
minifyURLs: true,
287-
},
288-
}),
289-
new HtmlWebpackPlugin({
290-
inject: true,
291-
chunks: ['common-sandbox', 'common', 'embed'],
292-
filename: 'embed.html',
293-
template: path.join(paths.embedSrc, 'index.html'),
294-
minify: __PROD__ && {
295-
removeComments: true,
296-
collapseWhitespace: true,
297-
removeRedundantAttributes: true,
298-
useShortDoctype: true,
299-
removeEmptyAttributes: true,
300-
removeStyleLinkTypeAttributes: true,
301-
keepClosingSlash: true,
302-
minifyJS: true,
303-
minifyCSS: true,
304-
minifyURLs: true,
305-
},
306-
}),
254+
...(SANDBOX_ONLY
255+
? [
256+
new HtmlWebpackPlugin({
257+
inject: true,
258+
chunks: ['sandbox-startup', 'sandbox'],
259+
filename: 'frame.html',
260+
template: paths.sandboxHtml,
261+
minify: __PROD__ && {
262+
removeComments: true,
263+
collapseWhitespace: true,
264+
removeRedundantAttributes: true,
265+
useShortDoctype: true,
266+
removeEmptyAttributes: true,
267+
removeStyleLinkTypeAttributes: true,
268+
keepClosingSlash: true,
269+
minifyJS: true,
270+
minifyCSS: true,
271+
minifyURLs: true,
272+
},
273+
}),
274+
]
275+
: [
276+
// Generates an `index.html` file with the <script> injected.
277+
new HtmlWebpackPlugin({
278+
inject: true,
279+
chunks: ['common-sandbox', 'common', 'app'],
280+
filename: 'app.html',
281+
template: paths.appHtml,
282+
minify: __PROD__ && {
283+
removeComments: false,
284+
collapseWhitespace: true,
285+
removeRedundantAttributes: true,
286+
useShortDoctype: true,
287+
removeEmptyAttributes: true,
288+
removeStyleLinkTypeAttributes: true,
289+
keepClosingSlash: true,
290+
minifyJS: true,
291+
minifyCSS: true,
292+
minifyURLs: true,
293+
},
294+
}),
295+
new HtmlWebpackPlugin({
296+
inject: true,
297+
chunks: ['sandbox-startup', 'common-sandbox', 'sandbox'],
298+
filename: 'frame.html',
299+
template: paths.sandboxHtml,
300+
minify: __PROD__ && {
301+
removeComments: true,
302+
collapseWhitespace: true,
303+
removeRedundantAttributes: true,
304+
useShortDoctype: true,
305+
removeEmptyAttributes: true,
306+
removeStyleLinkTypeAttributes: true,
307+
keepClosingSlash: true,
308+
minifyJS: true,
309+
minifyCSS: true,
310+
minifyURLs: true,
311+
},
312+
}),
313+
new HtmlWebpackPlugin({
314+
inject: true,
315+
chunks: ['common-sandbox', 'common', 'embed'],
316+
filename: 'embed.html',
317+
template: path.join(paths.embedSrc, 'index.html'),
318+
minify: __PROD__ && {
319+
removeComments: true,
320+
collapseWhitespace: true,
321+
removeRedundantAttributes: true,
322+
useShortDoctype: true,
323+
removeEmptyAttributes: true,
324+
removeStyleLinkTypeAttributes: true,
325+
keepClosingSlash: true,
326+
minifyJS: true,
327+
minifyCSS: true,
328+
minifyURLs: true,
329+
},
330+
}),
331+
]),
307332
// Makes some environment variables available to the JS code, for example:
308333
// if (process.env.NODE_ENV === 'development') { ... }. See `env.js`.
309334
new webpack.DefinePlugin(env),
@@ -323,10 +348,11 @@ module.exports = {
323348

324349
// With this plugin we override the load-rules of eslint, this function prevents
325350
// us from using eslint in the browser, therefore we need to stop it!
326-
new webpack.NormalModuleReplacementPlugin(
327-
new RegExp(['eslint', 'lib', 'load-rules'].join(`\\${path.sep}`)),
328-
path.join(paths.config, 'stubs/load-rules.compiled.js')
329-
),
351+
!SANDBOX_ONLY &&
352+
new webpack.NormalModuleReplacementPlugin(
353+
new RegExp(['eslint', 'lib', 'load-rules'].join(`\\${path.sep}`)),
354+
path.join(paths.config, 'stubs/load-rules.compiled.js')
355+
),
330356

331357
// If you require a missing module and then `npm install` it, you still have
332358
// to restart the development server for Webpack to discover it. This plugin
@@ -356,23 +382,28 @@ module.exports = {
356382
},
357383
].filter(x => x)
358384
),
359-
// We first create a common chunk between embed and app, to share components
360-
// and dependencies.
361-
new webpack.optimize.CommonsChunkPlugin({
362-
name: 'common',
363-
chunks: ['app', 'embed'],
364-
}),
365-
// Then we find all commonalities between sandbox and common, because sandbox
366-
// is always loaded by embed and app.
367-
new webpack.optimize.CommonsChunkPlugin({
368-
name: 'common-sandbox',
369-
chunks: ['common', 'sandbox'],
370-
}),
371-
new webpack.optimize.CommonsChunkPlugin({
372-
async: true,
373-
children: true,
374-
minChunks: 2,
375-
}),
385+
386+
...(SANDBOX_ONLY
387+
? []
388+
: [
389+
// We first create a common chunk between embed and app, to share components
390+
// and dependencies.
391+
new webpack.optimize.CommonsChunkPlugin({
392+
name: 'common',
393+
chunks: ['app', 'embed'],
394+
}),
395+
// Then we find all commonalities between sandbox and common, because sandbox
396+
// is always loaded by embed and app.
397+
new webpack.optimize.CommonsChunkPlugin({
398+
name: 'common-sandbox',
399+
chunks: ['common', 'sandbox'],
400+
}),
401+
new webpack.optimize.CommonsChunkPlugin({
402+
async: true,
403+
children: true,
404+
minChunks: 2,
405+
}),
406+
]),
376407
new webpack.NamedModulesPlugin(),
377-
],
408+
].filter(Boolean),
378409
};

packages/app/package.json

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"start:dev_api": "node scripts/start.js",
99
"start:test": "cross-env LOCAL_SERVER=1 NODE_ENV=test SANDBOX_ONLY=true node scripts/start.js",
1010
"build": "NODE_ENV=production node scripts/build.js",
11+
"build:sandbox": "cross-env NODE_ENV=production SANDBOX_ONLY=true node scripts/build.js",
1112
"test": "jest --env=jsdom",
1213
"test:watch": "jest --watch --env=jsdom",
1314
"test:integrations": "jest --config integration-tests/jest.config.json --maxWorkers=2",
@@ -74,7 +75,6 @@
7475
"react-test-renderer": "16",
7576
"recursive-readdir": "^2.2.1",
7677
"rimraf": "^2.6.1",
77-
"run-sequence": "^1.2.2",
7878
"strip-ansi": "3.0.1",
7979
"style-loader": "^0.18.2",
8080
"sw-precache-webpack-plugin": "^0.11.4",
@@ -88,7 +88,6 @@
8888
"webpack-manifest-plugin": "^1.3.2",
8989
"webpack-merge": "^4.1.0",
9090
"whatwg-fetch": "^2.0.3",
91-
"why-did-you-update": "^0.1.0",
9291
"worker-loader": "^0.8.1"
9392
},
9493
"dependencies": {
@@ -135,7 +134,6 @@
135134
"gulp-rev": "^7.1.2",
136135
"hash-sum": "^1.0.2",
137136
"humps": "CompuIves/humps",
138-
"image-extensions": "^1.1.0",
139137
"immer": "^0.8.5",
140138
"is-url": "^1.2.2",
141139
"jest-circus": "^22.1.4",
@@ -151,7 +149,6 @@
151149
"monaco-editor": "CompuIves/codesandbox-monaco-editor",
152150
"monaco-vue": "^0.2.1",
153151
"normalize.css": "^5.0.0",
154-
"normalizr": "^3.2.3",
155152
"postcss": "^6.0.9",
156153
"postcss-selector-parser": "^2.2.3",
157154
"posthtml": "^0.11.3",
@@ -162,32 +159,22 @@
162159
"rc-slider": "^8.2.0",
163160
"react": "16.2.0",
164161
"react-addons-css-transition-group": "^15.6.0",
165-
"react-deep-force-update": "^2.0.1",
166162
"react-dnd": "^2.4.0",
167163
"react-dnd-html5-backend": "^2.4.1",
168164
"react-dom": "16.2.0",
169165
"react-draggable": "^3.0.4",
170-
"react-draggable-tabs": "^1.0.7",
171166
"react-error-overlay": "^1.0.10",
172167
"react-icons": "^2.2.7",
173168
"react-inspector": "^2.2.0",
174169
"react-instantsearch": "^4.0.6",
175170
"react-loadable": "^3.3.1",
176-
"react-media": "^1.6.1",
177171
"react-modal": "^2.2.1",
178172
"react-motion": "^0.5.0",
179-
"react-redux": "^5.0.5",
180173
"react-router-dom": "^4.2.2",
181-
"react-router-redux": "next",
182174
"react-show": "^2.0.0",
183175
"react-split-pane": "^0.1.74",
184176
"react-stripe-elements": "^1.2.0",
185177
"react-tagsinput": "^3.19.0",
186-
"react-tippy": "^0.14.0",
187-
"redbox-react": "^1.4.3",
188-
"redux": "^3.7.1",
189-
"reselect": "^3.0.1",
190-
"script-ext-html-webpack-plugin": "^1.8.8",
191178
"shelljs": "^0.7.8",
192179
"store": "^2.0.12",
193180
"string-replace-loader": "^1.3.0",

0 commit comments

Comments
 (0)