Skip to content

Commit 36d8157

Browse files
author
zetlen
committed
fix(dev): merge 'assets' and 'output' paths
- Remove the concept of the "assets" directory entirely, and set the "output" directory to be just "web/". - Remove the old logo asset from /web/ (pre-Venia rebrand!) - Gitignore entire "web" directory - Set JS files to output to 'web/js' subdirectory by adding directory prefix to `output.filename` and `output.chunkFilename` - Modify tests, documentation, and type expectations to remove `paths.assets`
1 parent d0e4e03 commit 36d8157

File tree

17 files changed

+35
-77
lines changed

17 files changed

+35
-77
lines changed

.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
__fixtures__
22
dist
33
pwa-devdocs
4+
packages/venia-concept/web

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ test-report.xml
1111
test-results.json
1212
lerna-debug.log
1313
.env
14+
packages/venia-concept/web

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ package-lock.json
33
dist
44
web/js
55
pwa-devdocs
6+
packages/venia-concept/web

packages/pwa-buildpack/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,7 @@ which reads an ini-formatted file to set the environment.
218218
219219
const themePaths = {
220220
src: path.resolve(__dirname, 'src'),
221-
assets: path.resolve(__dirname, 'web'),
222-
output: path.resolve(__dirname, 'web/js')
221+
output: path.resolve(__dirname, 'web')
223222
};
224223
```
225224

packages/pwa-buildpack/docs/PWADevServer.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ module.exports = async env => {
2121
backendDomain: 'https://magento2.localdomain',
2222
serviceWorkerFileName: 'sw.js',
2323
paths: {
24-
output: path.resolve(__dirname, 'web/js'),
25-
assets: path.resolve(__dirname, 'web')
24+
output: path.resolve(__dirname, 'web/'),
2625
},
2726
id: 'magento-venia'
2827
})

packages/pwa-buildpack/docs/ServiceWorkerPlugin.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ module.exports = async env => {
3333
},
3434

3535
paths: {
36-
output: path.resolve(__dirname, 'web/js'),
37-
assets: path.resolve(__dirname, 'web')
36+
output: path.resolve(__dirname, 'web')
3837
},
3938
enableServiceWorkerDebugging: true,
4039
serviceWorkerFileName: 'sw.js',
@@ -63,9 +62,9 @@ Plugin constructor for the `ServiceWorkerPlugin` class.
6362
`paths: Object` **(Required)**
6463
The local absolute paths to theme folders.
6564

66-
- `paths.assets: String`
65+
- `paths.output: String`
6766

68-
The directory for public static assets.
67+
The directory for build output.
6968

7069
`enableServiceWorkerDebugging: Boolean`
7170
When `true`, hot reloading is enabled and the ServiceWorker is active in the document root, regardless of the publicPath value.

packages/pwa-buildpack/src/WebpackTools/PWADevServer.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ const PWADevServer = {
1919
publicPath: 'string',
2020
backendDomain: 'string',
2121
'paths.output': 'string',
22-
'paths.assets': 'string',
2322
serviceWorkerFileName: 'string'
2423
}),
2524
hostnamesById: new GlobalConfig({
@@ -165,7 +164,7 @@ const PWADevServer = {
165164
},
166165
after(app) {
167166
// set static server to load and serve from different paths
168-
app.use(config.publicPath, express.static(config.paths.assets));
167+
app.use(config.publicPath, express.static(config.paths.output));
169168

170169
// proxy to backend
171170
app.use(

packages/pwa-buildpack/src/WebpackTools/__tests__/PWADevServer.spec.js

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,15 +218,15 @@ test('.configure() throws errors on missing config', async () => {
218218
id: 'foo',
219219
publicPath: 'bar',
220220
backendDomain: 'https://dumb.domain',
221-
paths: { output: 'output' }
221+
paths: { output: 1234 }
222222
})
223-
).rejects.toThrow('paths.assets must be of type string');
223+
).rejects.toThrow('paths.output must be of type string');
224224
await expect(
225225
PWADevServer.configure({
226226
id: 'foo',
227227
publicPath: 'bar',
228228
backendDomain: 'https://dumb.domain',
229-
paths: { output: 'foo', assets: 'bar' }
229+
paths: { output: 'foo' }
230230
})
231231
).rejects.toThrow('serviceWorkerFileName must be of type string');
232232
});
@@ -243,8 +243,7 @@ test('.configure() gets or creates an SSL cert', async () => {
243243
const server = await PWADevServer.configure({
244244
id: 'heckin',
245245
paths: {
246-
output: 'good',
247-
assets: 'boye'
246+
output: 'good'
248247
},
249248
publicPath: 'bork',
250249
serviceWorkerFileName: 'doin',
@@ -267,8 +266,7 @@ test('.configure() returns a configuration object for the `devServer` property o
267266
const config = {
268267
id: 'Theme_Unique_Id',
269268
paths: {
270-
output: 'path/to/static',
271-
assets: 'path/to/assets'
269+
output: 'path/to/static'
272270
},
273271
publicPath: 'full/path/to/publicPath',
274272
serviceWorkerFileName: 'swname.js',
@@ -307,8 +305,7 @@ test('.configure() returns a configuration object with before() and after() hand
307305
const config = {
308306
id: 'Theme_Unique_Id',
309307
paths: {
310-
output: 'path/to/static',
311-
assets: 'path/to/assets'
308+
output: 'path/to/static'
312309
},
313310
publicPath: 'full/path/to/publicPath',
314311
serviceWorkerFileName: 'swname.js',
@@ -364,8 +361,7 @@ test('.configure() optionally adds OriginSubstitution middleware', async () => {
364361
const config = {
365362
id: 'Theme_Unique_Id',
366363
paths: {
367-
output: 'path/to/static',
368-
assets: 'path/to/assets'
364+
output: 'path/to/static'
369365
},
370366
publicPath: 'full/path/to/publicPath',
371367
serviceWorkerFileName: 'swname.js',

packages/pwa-buildpack/src/WebpackTools/plugins/ServiceWorkerPlugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class ServiceWorkerPlugin {
77
static validateOptions = optionsValidator('ServiceWorkerPlugin', {
88
'env.phase': 'string',
99
serviceWorkerFileName: 'string',
10-
'paths.assets': 'string'
10+
'paths.output': 'string'
1111
});
1212
constructor(config) {
1313
ServiceWorkerPlugin.validateOptions('ServiceWorkerPlugin', config);
@@ -17,7 +17,7 @@ class ServiceWorkerPlugin {
1717
const config = {
1818
// `globDirectory` and `globPatterns` must match at least 1 file
1919
// otherwise workbox throws an error
20-
globDirectory: this.config.paths.assets,
20+
globDirectory: this.config.paths.output,
2121
// TODO: (feature) autogenerate glob patterns from asset manifest
2222
globPatterns: ['**/*.{gif,jpg,png,svg}'],
2323

packages/pwa-buildpack/src/WebpackTools/plugins/__tests__/ServiceWorkerPlugin.spec.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test('throws if options are missing', () => {
1919
env: { phase: 'development' },
2020
serviceWorkerFileName: 'file.name'
2121
})
22-
).toThrow('paths.assets must be of type string');
22+
).toThrow('paths.output must be of type string');
2323
});
2424

2525
test('returns a valid Webpack plugin', () => {
@@ -31,7 +31,7 @@ test('returns a valid Webpack plugin', () => {
3131
serviceWorkerFileName: 'sw.js',
3232
runtimeCacheAssetPath: 'https://location/of/assets',
3333
paths: {
34-
assets: 'path/to/assets'
34+
output: 'path/to/assets'
3535
}
3636
})
3737
).toHaveProperty('apply', expect.any(Function));
@@ -45,7 +45,7 @@ test('.apply calls WorkboxPlugin.GenerateSW in prod', () => {
4545
serviceWorkerFileName: 'sw.js',
4646
runtimeCacheAssetPath: 'https://location/of/assets',
4747
paths: {
48-
assets: 'path/to/assets'
48+
output: 'path/to/assets'
4949
}
5050
});
5151
const workboxApply = jest.fn();
@@ -75,7 +75,7 @@ test('.apply calls nothing but warns in console in dev', () => {
7575
serviceWorkerFileName: 'sw.js',
7676
runtimeCacheAssetPath: 'https://location/of/assets',
7777
paths: {
78-
assets: 'path/to/assets'
78+
output: 'path/to/assets'
7979
}
8080
});
8181
jest.spyOn(console, 'warn').mockImplementationOnce(() => {});
@@ -103,7 +103,7 @@ test('.apply generates and writes out a serviceworker when enableServiceWorkerDe
103103
serviceWorkerFileName: 'sw.js',
104104
runtimeCacheAssetPath: 'https://location/of/assets',
105105
paths: {
106-
assets: 'path/to/assets'
106+
output: 'path/to/assets'
107107
}
108108
});
109109

0 commit comments

Comments
 (0)