Webpack:关于__dirname如何上升一个或多个级别?

时间:2017-12-26 02:50:10

标签: javascript node.js webpack directory

以下配置有效,但我有理由从项目根目录移动webpack配置。因此,__dirname值会发生变化,我需要转到__dirname的上限。怎么做?

const output_path = isDevelopment ? (__dirname + '/development/devBuild') : (__dirname + '/public');

module.exports = {

    entry: {
        'open/js/testOpenEntryPoint': './development/source/open/es6/testOpenEntryPoint',
        'admin/js/testAdminEntryPoint': './development/source/admin/es6/testAdminEntryPoint'
    }

    output: {
        path: output_path,
        filename: '[name].js'
    },

    // ...
}

1 个答案:

答案 0 :(得分:0)

const projectRootDirectory = __dirname + '/../../..';
const output_path = options.isDevelopment ? (projectRootDirectory + '/development/devBuild') : (projectRootDirectory + '/public');

会做的。