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