简体   繁体   中英

Make webpack move files from src to dest without processing it

I have some sites running with JSF and some vanilla ES6 that is being processed with webpack (Running 4.6).

The problem is that webpack adds something to my jsf.js file when it moves the file to my dest folder, and doesn't work with how JSF needs to be run.

Setup: There is the jsf.js and the vanilla ES6 files in a src folder. I then use webpack to process and move the bundle and the jsf.js file to a dest folder.

The JSF.js file is already minimized in the src folder and cannot be uglified so I have added exclude on uglify:

 optimization: {
    minimizer: [
      new UglifyJsPlugin({
        exclude: /(jsf.js)/,
      })
    ]
  }

The jsf.js also has its own entry btw.

So my question is, how do I make webpack only move the jsf.js and add nothing to it? There must be some kind of exclude that I am missing here. I use no plugins other than uglify.

If you just want copy jsf.js to dist directory. you should try copy-webpack-plugin , not give it its own entry.

install it throught npm:

npm i -D copy-webpack-plugin

require it in webpack.config.js

const CopyWebpackPlugin = require('copy-webpack-plugin')

add to plugins's array

[
  new CopyWebpackPlugin([
    { from: 'path/to/jsf.js', to: 'dist/' }
  ])
]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM