Webpack: Want to have files in root

Created on 6 Apr 2017  Â·  5Comments  Â·  Source: vuejs-templates/webpack

Hi,

I currently have a lot of files, which are normally meant to be in the ROOT directory of the project, inside the static directory. Now I literally have no idea, how to get these files to be in the ROOT directory, when the project is going to get builded.

Any1 got a solution for me?

Most helpful comment

Fixed it myself by adding a directory root/, copying the files over there and extending webpack.prod.conf.js copytask with this:

    new CopyWebpackPlugin([
      {
        from: path.resolve(__dirname, '../static'),
        to: config.build.assetsSubDirectory,
        ignore: ['.*']
      },
      {
        from: path.resolve(__dirname, '../root'),
        to: config.build.assetsRoot,
        ignore: ['.*']
      }
    ])

All 5 comments

Fixed it myself by adding a directory root/, copying the files over there and extending webpack.prod.conf.js copytask with this:

    new CopyWebpackPlugin([
      {
        from: path.resolve(__dirname, '../static'),
        to: config.build.assetsSubDirectory,
        ignore: ['.*']
      },
      {
        from: path.resolve(__dirname, '../root'),
        to: config.build.assetsRoot,
        ignore: ['.*']
      }
    ])

For me the above solution from @visualcookie didn't work, getting this error:

Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: [BABEL] /Users/pear/projects/gekko-develop/web/vue/src/main.js: .apply is not a valid Plugin property

instead I had to move the CopyWebpackPlugin config into a new file vue.config.js like so:

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

module.exports = {
  configureWebpack: {
    plugins: [
      new CopyWebpackPlugin([
        {
          from: '../baseUIconfig.js',
          to: 'public/UIconfig.js'
        }
      ])
    ]
  }
}

See these docs: https://cli.vuejs.org/guide/webpack.html#simple-configuration

@askmike Thanks for the response. It did work, but my post is from last year, so yeah... version has changed and such.

I know, I was just commenting my findings for future readers. Took me an
hour to figure out, so maybe I can save the next person that time (until it
changes again).

On Wed, 11 Jul 2018, 08:00 Dean Hidri, notifications@github.com wrote:

@askmike https://github.com/askmike Thanks for the response. It did
work, but my post is from last year, so yeah... version has changed and
such.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/vuejs-templates/webpack/issues/657#issuecomment-404002546,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA7MD10DD-oPcGzdgQzCAzvLVX8xqOe6ks5uFUAWgaJpZM4M1sp5
.

@askmike Extending the existing CopyWebpackPlugin with

{
    from: path.resolve(__dirname, '../root'),
    to: config.build.assetsRoot
}

worked for me.

new CopyWebpackPlugin([
        {
            from: path.resolve(__dirname, '../static'),
            to: config.build.assetsSubDirectory,
            ignore: ['.*']
        },
        {
            from: path.resolve(__dirname, '../root'),
            to: config.build.assetsRoot
        }
]),

VueJS ^2.5.2

Was this page helpful?
0 / 5 - 0 ratings