sheerun / babel-plugin-file-loader

Like webpack's file-loader, but on server side. Allows for production-grade require('./file.png')
MIT License
38 stars 17 forks source link

Add root path to options #33

Open thenengah opened 3 years ago

thenengah commented 3 years ago

https://github.com/sheerun/babel-plugin-file-loader/issues/7

Fix for this issue.

babelRegister({
  cache: false,
  extensions: ['.js'],
  presets: [
    ['@babel/preset-env'],
    ['@babel/preset-react']
  ],
  plugins: [
    ['@babel/plugin-transform-runtime'],
    ['babel-plugin-transform-require-ignore', {
      extensions: ['.css', '.scss']
    }],
    ['babel-plugin-file-loader', {
      rootPath: '../',
      publicPath: '/dist',
      outputPath: '/public/dist'
    }]
  ]
})

Example usage with @babel/register