webpack-blocks-copy
v1.0.2
Published
A webpack-block for copy-webpack-plugin
Downloads
7
Maintainers
Readme
webpack-blocks-copy
A webpack-block for copy-webpack-plugin.
Installation
yarn add --dev webpack-blocks-copy
or
npm install --save-dev webpack-blocks-copy
Usage
The most basic way to use the plugin is to import copy
and use it to define simple from, to pairs that are added to the list of patterns used when the plugin is instantiated.
import {createConfig, entryPoint, setOutput} from '@webpack-blocks/webpack2'
import babel from '@webpack-blocks/babel6'
import {copy} from './src/webpack-block-copy'
export default createConfig([
entryPoint(['babel-polyfill', './src/Main.js']),
setOutput('./build/bundle.js'),
babel(),
copy('assets/robots.txt', 'robots.txt'),
copy('assets/favicon.ico', 'favicon.ico'),
])
This would result in the following CopyPlugin config:
new CopyWebpackPlugin([
{from: 'assets/robots.txt', to: 'robots.txt'},
{from: 'assets/favicon.ico', to: 'favicon.ico'},
])
Advanced patterns
If you need to use more advanced patterns, described here, use the copyPattern
function:
import {createConfig} from '@webpack-blocks/webpack2'
import {copyPattern} from './src/webpack-block-copy'
export default createConfig([
copyPattern({
context: 'from/directory',
from: '**/*',
to: '/absolute/path',
}),
])
Options
If you need to set options, use the copyOptions
function:
import {createConfig} from '@webpack-blocks/webpack2'
import {copyOptions} from './src/webpack-block-copy'
export default createConfig([
copyOptions({copyUnmodified: true}),
])
See the options list here.
License
This project is licensed under MIT.