Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(generators): correct optimization.splitChunks option in config (#…
…2008) * fix(generators): update optimization.splitChunks option * tests: init-generator
- Loading branch information
Showing
3 changed files
with
290 additions
and
1 deletion.
There are no files selected for viewing
275 changes: 275 additions & 0 deletions
275
packages/generators/__tests__/__snapshots__/init-generator.test.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,275 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`init generator generates a webpack config that uses ES6 1`] = ` | ||
Object { | ||
"mode": "'development'", | ||
"module": Object { | ||
"rules": Array [ | ||
Object { | ||
"include": Array [ | ||
"path.resolve(__dirname, 'src')", | ||
], | ||
"loader": "'babel-loader'", | ||
"test": "/\\\\.(js|jsx)$/", | ||
}, | ||
], | ||
}, | ||
"optimization": Object { | ||
"minimizer": Array [ | ||
"new TerserPlugin()", | ||
], | ||
"splitChunks": Object { | ||
"cacheGroups": Object { | ||
"vendors": Object { | ||
"priority": -10, | ||
"test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", | ||
}, | ||
}, | ||
"chunks": "'async'", | ||
"minChunks": 1, | ||
"minSize": 30000, | ||
"name": false, | ||
}, | ||
}, | ||
"plugins": Array [ | ||
"new webpack.ProgressPlugin()", | ||
], | ||
} | ||
`; | ||
|
||
exports[`init generator generates a webpack config that uses Typescript 1`] = ` | ||
Object { | ||
"entry": "'./src/index.ts'", | ||
"mode": "'development'", | ||
"module": Object { | ||
"rules": Array [ | ||
Object { | ||
"exclude": Array [ | ||
"/node_modules/", | ||
], | ||
"include": Array [ | ||
"path.resolve(__dirname, 'src')", | ||
], | ||
"loader": "'ts-loader'", | ||
"test": "/\\\\.(ts|tsx)$/", | ||
}, | ||
], | ||
}, | ||
"optimization": Object { | ||
"minimizer": Array [ | ||
"new TerserPlugin()", | ||
], | ||
"splitChunks": Object { | ||
"cacheGroups": Object { | ||
"vendors": Object { | ||
"priority": -10, | ||
"test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", | ||
}, | ||
}, | ||
"chunks": "'async'", | ||
"minChunks": 1, | ||
"minSize": 30000, | ||
"name": false, | ||
}, | ||
}, | ||
"plugins": Array [ | ||
"new webpack.ProgressPlugin()", | ||
], | ||
"resolve": Object { | ||
"extensions": Array [ | ||
"'.tsx'", | ||
"'.ts'", | ||
"'.js'", | ||
], | ||
}, | ||
} | ||
`; | ||
|
||
exports[`init generator generates a webpack config using CSS with mini-css-extract-plugin 1`] = ` | ||
Object { | ||
"mode": "'development'", | ||
"module": Object { | ||
"rules": Array [ | ||
Object { | ||
"test": "/.css$/", | ||
"use": Array [ | ||
Object { | ||
"loader": "MiniCssExtractPlugin.loader", | ||
}, | ||
Object { | ||
"loader": "\\"style-loader\\"", | ||
}, | ||
Object { | ||
"loader": "\\"css-loader\\"", | ||
"options": Object { | ||
"sourceMap": true, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
"optimization": Object { | ||
"minimizer": Array [ | ||
"new TerserPlugin()", | ||
], | ||
"splitChunks": Object { | ||
"cacheGroups": Object { | ||
"vendors": Object { | ||
"priority": -10, | ||
"test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", | ||
}, | ||
}, | ||
"chunks": "'async'", | ||
"minChunks": 1, | ||
"minSize": 30000, | ||
"name": false, | ||
}, | ||
}, | ||
"plugins": Array [ | ||
"new webpack.ProgressPlugin()", | ||
"new MiniCssExtractPlugin({ filename:'main.[chunkhash].css' })", | ||
], | ||
} | ||
`; | ||
|
||
exports[`init generator generates a webpack config using CSS without mini-css-extract-plugin 1`] = ` | ||
Object { | ||
"mode": "'development'", | ||
"module": Object { | ||
"rules": Array [ | ||
Object { | ||
"test": "/.css$/", | ||
"use": Array [ | ||
Object { | ||
"loader": "\\"style-loader\\"", | ||
}, | ||
Object { | ||
"loader": "\\"css-loader\\"", | ||
"options": Object { | ||
"sourceMap": true, | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
"optimization": Object { | ||
"minimizer": Array [ | ||
"new TerserPlugin()", | ||
], | ||
"splitChunks": Object { | ||
"cacheGroups": Object { | ||
"vendors": Object { | ||
"priority": -10, | ||
"test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", | ||
}, | ||
}, | ||
"chunks": "'async'", | ||
"minChunks": 1, | ||
"minSize": 30000, | ||
"name": false, | ||
}, | ||
}, | ||
"plugins": Array [ | ||
"new webpack.ProgressPlugin()", | ||
], | ||
} | ||
`; | ||
|
||
exports[`init generator generates a webpack config with custom entry and output 1`] = ` | ||
Object { | ||
"entry": "'./src/index2.js'", | ||
"mode": "'development'", | ||
"module": Object { | ||
"rules": Array [], | ||
}, | ||
"optimization": Object { | ||
"minimizer": Array [ | ||
"new TerserPlugin()", | ||
], | ||
"splitChunks": Object { | ||
"cacheGroups": Object { | ||
"vendors": Object { | ||
"priority": -10, | ||
"test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", | ||
}, | ||
}, | ||
"chunks": "'async'", | ||
"minChunks": 1, | ||
"minSize": 30000, | ||
"name": false, | ||
}, | ||
}, | ||
"output": Object { | ||
"path": "path.resolve(__dirname, 'dist2')", | ||
}, | ||
"plugins": Array [ | ||
"new webpack.ProgressPlugin()", | ||
], | ||
} | ||
`; | ||
|
||
exports[`init generator generates a webpack config with default options 1`] = ` | ||
Object { | ||
"devServer": Object { | ||
"open": true, | ||
}, | ||
"mode": "'production'", | ||
"module": Object { | ||
"rules": Array [], | ||
}, | ||
"optimization": Object { | ||
"minimizer": Array [ | ||
"new TerserPlugin()", | ||
], | ||
"splitChunks": Object { | ||
"chunks": "'all'", | ||
}, | ||
}, | ||
"plugins": Array [ | ||
"new webpack.ProgressPlugin()", | ||
"new HtmlWebpackPlugin({ | ||
template: 'index.html' | ||
})", | ||
"new workboxPlugin.GenerateSW({ | ||
swDest: 'sw.js', | ||
clientsClaim: true, | ||
skipWaiting: false, | ||
})", | ||
], | ||
} | ||
`; | ||
|
||
exports[`init generator generates a webpack config with multiple entries 1`] = ` | ||
Object { | ||
"entry": Object { | ||
"test1": "'./dir1/test1.js'", | ||
"test2": "'./dir2/test2.js'", | ||
}, | ||
"mode": "'development'", | ||
"module": Object { | ||
"rules": Array [], | ||
}, | ||
"optimization": Object { | ||
"minimizer": Array [ | ||
"new TerserPlugin()", | ||
], | ||
"splitChunks": Object { | ||
"cacheGroups": Object { | ||
"vendors": Object { | ||
"priority": -10, | ||
"test": "/[\\\\\\\\/]node_modules[\\\\\\\\/]/", | ||
}, | ||
}, | ||
"chunks": "'async'", | ||
"minChunks": 1, | ||
"minSize": 30000, | ||
"name": false, | ||
}, | ||
}, | ||
"plugins": Array [ | ||
"new webpack.ProgressPlugin()", | ||
], | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters