Webpack2无法解析路径名

时间:2016-09-23 16:07:33

标签: reactjs webpack webpack-2

我有一个我似乎无法解决的奇怪问题。

我收到此错误:

Error: Can't resolve 'store/configureStore' in '/Users/samboy/company/oh-frontend/app'

我的webpack文件如下所示:

   name: 'browser',
    context: path.join(__dirname, '..', '..', '..', 'app'),
    entry: {
      app: './client'
    },
    output: {
      // The output directory as absolute path
      path: assetsPath,
      // The filename of the entry chunk as relative path inside the output.path directory
      filename: '[name].js',
      // The output path from the view of the Javascript
      publicPath: publicPath

    },

    module: {
      loaders: commonLoaders
    },
    resolve: {
      modules: [
        path.resolve(__dirname, '..', '..', '..', 'app'),
        'node_modules'
      ],
      extensions: ['', '.js', '.jsx', '.css']
    },
    plugins: [
        // extract inline css from modules into separate files
        new ExtractTextPlugin('styles/bundled-modules.css'),
        // files in global directory should be concatenated into one file for prod
        new CopyWebpackPlugin([
            { from: 'fonts/', to: 'fonts/' }
            , { from: '_web/css/global/fonts.css', to: 'styles/fonts.css' }
            , { from: '_web/css/vendors', to: 'styles/vendors' }
        ]),
        new webpack.optimize.UglifyJsPlugin({
          compressor: {
            warnings: false
          }
        }),
        new webpack.DefinePlugin({
          __DEVCLIENT__: false,
          __DEVSERVER__: false,
          __PLATFORM_WEB__: true,
          __PLATFORM_IOS__: false
        }),
        new InlineEnviromentVariablesPlugin({ NODE_ENV: 'production' }),function()
    {
        this.plugin("done", function(stats)
        {
            if (stats.compilation.errors && stats.compilation.errors.length)
            {
                console.log(stats.compilation.errors);
                process.exit(1);
            }
            // ...
        });
    }
    ],
    postcss: postCSSConfig
  }

该文件肯定存在于该文件夹中。它与webpack一起运行良好。但它似乎不适用于webpack2。

1 个答案:

答案 0 :(得分:0)

我猜是因为您没有发布您的应用文件,但是您可以将应用文件中的import语句更改为" ./ store / configureStore"?