bugfix for manifest path, extend to merge plugins

main v0.6.0
HerrHase 2 weeks ago
parent 0e3461afa1
commit c0fa667d94

@ -16,7 +16,8 @@ const glob = require('glob')
* @link https://git.node001.net/tiny-components/webpack.git * @link https://git.node001.net/tiny-components/webpack.git
* *
*/ */
module.exports = function tinyComponentsWebpack(files, options = {}) {
module.exports = function tinyComponentsWebpack(files, options = {}) {
// merge options with defaults // merge options with defaults
const defaults = Object.assign({ const defaults = Object.assign({
@ -24,9 +25,9 @@ module.exports = function tinyComponentsWebpack(files, options = {}) {
destination: path.resolve(process.cwd(), 'public'), destination: path.resolve(process.cwd(), 'public'),
publicPath: '/', publicPath: '/',
purge: { purge: {
src: path.join(__dirname, 'js'), src: path.join(__dirname, 'js')
safelist: [] },
} plugins: []
}, options) }, options)
const config = { const config = {
@ -75,9 +76,10 @@ module.exports = function tinyComponentsWebpack(files, options = {}) {
filename: "fonts/[name].[ext]", filename: "fonts/[name].[ext]",
} }
}] }]
}, }
}
plugins: [ config.plugins = defaults.plugins.concat([
new RemoveEmptyScriptsPlugin(), new RemoveEmptyScriptsPlugin(),
new MiniCssExtractPlugin({ new MiniCssExtractPlugin({
filename: 'css/[name].css', filename: 'css/[name].css',
@ -88,10 +90,9 @@ module.exports = function tinyComponentsWebpack(files, options = {}) {
}), }),
new ManifestPlugin({ new ManifestPlugin({
filename: 'assets-manifest.json', filename: 'assets-manifest.json',
context: defaults.context context: defaults.destination
}) })
], ])
}
// if rules exists add // if rules exists add
if (defaults.rules) { if (defaults.rules) {
@ -101,7 +102,7 @@ module.exports = function tinyComponentsWebpack(files, options = {}) {
} }
// adding svg src // adding svg src
if (defaults.svg && defaults.svg.src) { if (defaults.svg.src) {
config.plugins.push(new SvgSpritemapPlugin(defaults.svg.src, { config.plugins.push(new SvgSpritemapPlugin(defaults.svg.src, {
output: { output: {
filename: 'symbol-defs.svg', filename: 'symbol-defs.svg',

@ -1,6 +1,6 @@
{ {
"name": "@tiny-components/webpack", "name": "@tiny-components/webpack",
"version": "0.5.2", "version": "0.6.0",
"description": "Webpack Wrapper", "description": "Webpack Wrapper",
"repository": { "repository": {
"type": "git", "type": "git",

Loading…
Cancel
Save