4

I have a server file that is created from src/server/index.js and bundled to and run from build/server.js. When importing modules everything works, but I am having and issue where a folder can't be found when using path.resolve.

I am doing something like this but once the server file is bundled the following path cannot be found. My guess is because I am not importing it and therefore it is never bundled.

path.resolve(__dirname, 'server/email_templates')

Is there a way to make sure that my application can find this folder after being bundled ?

I have tried to adding resolve object to my webpack config, but that seems to only work for requiring and importing modules, not using the path module. Here's my webpack config object.

entry: {
    app: path.join(__dirname, 'src/server/index.js')
},

output: {
    path: path.join(__dirname, 'build'),
    publicPath: '/assets/',
    filename: 'server.js',
    libraryTarget: 'commonjs2',
},

target: 'node',

module: {
    loaders: [
        {
            test: /(\.js|\.jsx)$/,
            exclude: /node_modules/,
            loader: 'babel',
            query: {
                presets: [
                    'react',
                    'node6',
                    'stage-0'
                ]
            }
        },
        serverUrlLoader,
        serverStyleLoader,
    ],
},

Folder Structure

src
|_____server
      |-index.js - entry point for bundle
      |_____email_templates
build
|_____server.bundle.js
pizzarob
  • 11,711
  • 6
  • 48
  • 69

0 Answers0