Skip to content

Commit

Permalink
webpack 5 updates
Browse files Browse the repository at this point in the history
  • Loading branch information
maier49 committed Sep 14, 2020
1 parent d403ece commit 52f409f
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 25 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@
"tsconfig-paths-webpack-plugin": "3.2.0",
"typed-css-modules": "0.3.1",
"umd-compat-loader": "2.1.1",
"webpack": "5.0.0-beta.29",
"webpack": "5.0.0-beta.30",
"webpack-hot-middleware": "2.24.3",
"webpack-manifest-plugin": "3.0.0-rc.0",
"webpack-mild-compile": "3.3.1",
"webpack-pwa-manifest": "3.7.1",
"webpack-pwa-manifest": "4.2.0",
"wrapper-webpack-plugin": "2.0.0"
}
}
6 changes: 6 additions & 0 deletions src/base.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,12 @@ export default function webpackConfigFactory(args: any): webpack.Configuration {
// `file` uses the pattern `loaderPath!filePath`, hence the regex test
noParse: (file: string) => assetsDirPattern.test(file),
rules: removeEmpty([
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
},
{
test: indexHtmlPattern,
use: {
Expand Down
6 changes: 5 additions & 1 deletion src/dev.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ function webpackConfig(args: any): webpack.Configuration {
base,
inject: true,
chunks: [entryName],
meta: manifest ? { 'mobile-web-app-capable': 'yes' } : {},
meta: manifest
? {
'mobile-web-app-capable': 'yes'
}
: {},
template: 'src/index.html',
cache: false
}),
Expand Down
12 changes: 8 additions & 4 deletions src/dist.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,11 @@ function webpackConfig(args: any): webpack.Configuration {
base,
inject: true,
chunks: [entryName],
meta: manifest ? { 'mobile-web-app-capable': 'yes' } : {},
meta: manifest
? {
'mobile-web-app-capable': 'yes'
}
: {},
template: 'src/index.html',
cache: false
}),
Expand Down Expand Up @@ -167,7 +171,7 @@ function webpackConfig(args: any): webpack.Configuration {
config.plugins = config.plugins.map((plugin: any) => {
if (plugin instanceof MiniCssExtractPlugin) {
return new MiniCssExtractPlugin({
filename: args.omitHash ? '[name].bundle.css' : '[name].[contenthash].bundle.css'
filename: args.omitHash ? '[name].bundle.css' : '[name].bundle.css'
});
}
return plugin;
Expand Down Expand Up @@ -215,8 +219,8 @@ function webpackConfig(args: any): webpack.Configuration {
config.output = {
...output,
path: outputPath,
chunkFilename: args.omitHash ? '[name].bundle.js' : '[name].[chunkhash].bundle.js',
filename: args.omitHash ? '[name].bundle.js' : '[name].[chunkhash].bundle.js'
chunkFilename: args.omitHash ? '[name].bundle.js' : '[name].bundle.js',
filename: args.omitHash ? '[name].bundle.js' : '[name].bundle.js'
};

return config;
Expand Down
8 changes: 4 additions & 4 deletions src/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,10 @@
"strategy": {
"type": "string",
"enum": [
"networkFirst",
"cacheFirst",
"networkOnly",
"staleWhileRevalidate"
"NetworkFirst",
"CacheFirst",
"NetworkOnly",
"StaleWhileRevalidate"
]
},
"expiration": {
Expand Down
4 changes: 2 additions & 2 deletions test-app/.dojorc-dev-pwa
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"clientsClaim": true,
"excludeBundles": [ "src/LazyWidget" ],
"routes": [
{ "urlPattern": "\\.(jpg|png|gif|svg)$", "strategy": "cacheFirst", "expiration": { "maxEntries": 25 } },
{ "urlPattern": "/api", "strategy": "networkFirst" }
{ "urlPattern": "\\.(jpg|png|gif|svg)$", "strategy": "CacheFirst", "expiration": { "maxEntries": 25 } },
{ "urlPattern": "/api", "strategy": "NetworkFirst" }
]
}
},
Expand Down
4 changes: 2 additions & 2 deletions test-app/.dojorc-dev-pwa-evergreen
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"clientsClaim": true,
"excludeBundles": [ "src/LazyWidget" ],
"routes": [
{ "urlPattern": "\\.(jpg|png|gif|svg)$", "strategy": "cacheFirst", "expiration": { "maxEntries": 25 } },
{ "urlPattern": "/api", "strategy": "networkFirst" }
{ "urlPattern": "\\.(jpg|png|gif|svg)$", "strategy": "CacheFirst", "expiration": { "maxEntries": 25 } },
{ "urlPattern": "/api", "strategy": "NetworkFirst" }
]
}
},
Expand Down
4 changes: 2 additions & 2 deletions test-app/.dojorc-dist-pwa
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"clientsClaim": true,
"excludeBundles": [ "src/LazyWidget" ],
"routes": [
{ "urlPattern": "\\.(jpg|png|gif|svg)$", "strategy": "cacheFirst", "expiration": { "maxEntries": 25 } },
{ "urlPattern": "/api", "strategy": "networkFirst" }
{ "urlPattern": "\\.(jpg|png|gif|svg)$", "strategy": "CacheFirst", "expiration": { "maxEntries": 25 } },
{ "urlPattern": "/api", "strategy": "NetworkFirst" }
]
}
},
Expand Down
4 changes: 2 additions & 2 deletions test-app/.dojorc-dist-pwa-evergreen
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"clientsClaim": true,
"excludeBundles": [ "src/LazyWidget" ],
"routes": [
{ "urlPattern": "\\.(jpg|png|gif|svg)$", "strategy": "cacheFirst", "expiration": { "maxEntries": 25 } },
{ "urlPattern": "/api", "strategy": "networkFirst" }
{ "urlPattern": "\\.(jpg|png|gif|svg)$", "strategy": "CacheFirst", "expiration": { "maxEntries": 25 } },
{ "urlPattern": "/api", "strategy": "NetworkFirst" }
]
}
},
Expand Down
12 changes: 6 additions & 6 deletions tests/integration/build.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
describe('build', () => {
function testUrl(dir: string, isDist: boolean, isPwa: boolean) {
cy.visit(`/test-app/output/${dir}/`);
cy.get('#div').should(
'contain',
`Built with Build Time Render: true
Currently Rendered by BTR: false`
);
cy.get('#app-root').should('contain', 'Lazy Widget using dojorc configuration');
cy.get('#div').should('have.css', 'background-color', 'rgba(0, 0, 0, 0.5)');
cy.get('#vars').should('have.css', 'outline-color', 'rgba(255, 0, 0, 0.5)');
Expand All @@ -18,6 +13,11 @@ Currently Rendered by BTR: false`
cy.get('#div[has-prod=prod]').should(isDist ? 'exist' : 'not.exist');
cy.get('#div[dojo-debug=true]').should(isDist ? 'not.exist' : 'exist');
cy.get('#div[has-ci=ci]').should(isDist ? 'not.exist' : 'exist');
cy.get('#div').should(
'contain',
`Built with Build Time Render: true
Currently Rendered by BTR: false`
);

cy.get('meta[name="mobile-web-app-capable"]').should(isPwa ? 'exist' : 'not.exist');
cy.get('meta[name="apple-mobile-web-app-capable"]').should(isPwa ? 'exist' : 'not.exist');
Expand Down Expand Up @@ -54,7 +54,7 @@ Currently Rendered by BTR: false`
it('dev-pwa', () => {
testUrl('dev-pwa', false, true);
});
it('dev-app', () => {
it('dev-pwa-evergreen', () => {
testUrl('dev-pwa-evergreen', false, true);
});
});
Expand Down

0 comments on commit 52f409f

Please sign in to comment.