1.0.0 • Published 5 years ago

move-copy-chunk-webpack-plugin v1.0.0

Weekly downloads
6
License
MIT
Repository
github
Last release
5 years ago

npm build download coverage

npm i -D move-copy-chunk-webpack-plugin

webpack.config.js

const MoveCopyChunkPlugin = require('move-copy-chunk-webpack-plugin')
const config = {
  ...
  plugins: [
    new MoveCopyChunkPlugin([
      {
        actionType: 'copy',
        pattern: 'myChunkA.*.js',
        to: 'tmp.chunk.dir'
      },
      {
        actionType: 'move',
        pattern: 'myChunkB.*.js',
        to: 'moved.chunk.dir'
      }
    ])
  ]
}

Configuration

NameTypeDescription
actionType{String}The type of action that can be used move or copy
pattern{String\|RegEx}The chunk name to apply the action type, you can use RegEx to match chunk name minimatch options
to{String}The path to the destination folder.
context{String}Path from where the to should be resolved, by default compiler.options.context

actionType

webpack.config.js

[
  new MoveCopyChunkPlugin([
    {
      actionType: 'copy',
      pattern: 'myChunkA.*.js',
      to: 'copied.chunk.dir'
    },
    {
      actionType: 'move',
      pattern: 'myChunkB.*.js',
      to: 'moved.chunk.dir'
    }
  ])
]

pattern

webpack.config.js

[
  new MoveCopyChunkPlugin([
    {
      actionType: 'copy',
      pattern: '*.css',
      to: 'myTempDirectory'
    },
    {
      actionType: 'move',
      pattern: 'bundle.*.js',
      to: '/myTempDirectory'
    },
    {
      actionType: 'move',
      pattern: '*chunks.*.js',
      to: 'myChunksDir'
    }
  ])
]

to

webpack.config.js

[
  new MoveCopyChunkPlugin([
    {
      actionType: 'copy',
      pattern: 'myChunkA.*.js',
      to: 'myTempDirectory'
    },
    {
      actionType: 'move',
      pattern: 'myChunkB.*.js',
      to: '/myTempDirectory'
    }
  ])
]

context

[
  new MoveCopyChunkPlugin([
    {
      actionType: 'copy',
      pattern: 'myChunkA.*.js',
      to: 'myTempDirectory',
      context: 'chunks/'
    },
    {
      actionType: 'move',
      pattern: 'myChunkB.*.js',
      to: './src/asyncChunk'
    }
  ])
]

Optional options

NameTypeDescription
logInfo{Boolean}Enable or disable the log display for the moved or copied files (by default the value is true)

logInfo

[
  new MoveCopyChunkPlugin([
    {
      actionType: 'move',
      pattern: 'myChunkB.*.js',
      to: 'tmp/asyncChunk'
    }],
    { logInfo: false }
  )
]