问题标签 [webpack-2]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
1594 浏览

webpack - Export one of Webpack entry points as a library

I have Webpack configuration for transpiled app:

I would like to have polyfill and main to be loaded from <script> tag in browser, and lib to be exported as CommonJS library.

lib is used by Node backend but contains some of app modules, so it is built alongside with other entry points). The application is being transpiled, so it is not possible to just require modules from ./app in Node.

What are the options here? Is using separate Webpack configs and separate Webpack runs the only one?

0 投票
0 回答
191 浏览

javascript - webpack 2 从目录中动态导入文件

我有一个具有 dir 结构的反应应用程序:

我需要一些如何将所有 widget-x/reducers/index.js 导入 mainreducers/index.js。目前我正在尝试:

但这也从 anotherFolder 导入了其他 index.js (我确实找到的另一个解决方案是将 index.js (widgetX/reducer/) 名称重命名为 reduce.js 并使用 require.context 但这不是我需要的方式) .

谢谢。

0 投票
0 回答
50 浏览

html-webpack-plugin - 用于创建多个文件的 Webpack 配置

我正在尝试分别生成两个 css 文件(浅色和深色主题),以便我可以为我的应用程序构建一个主题切换器,以根据用户偏好加载任一样式。似乎无法让它在没有错误的情况下正常工作。

实际上,文件是按预期创建的,但我只想将其中一个注入到我的文档头中,只要我允许两者都被注入,一切正常。

我试图使用 chunks 或 excludeChunks 选项来影响哪些文件被注入到头部,但是当我使用这些选项时我不断收到错误。

webpackJsonp 未定义错误

0 投票
0 回答
942 浏览

javascript - Webpack 2:无法读取未定义的属性“Base64”

我是 Webpack 的新手。我的 React 配置有效,但是当我尝试import postcssJs from 'postcss-js'浏览器时,会Uncaught TypeError: Cannot read property 'Base64' of undefinedvar _Base64 = global.Base64;.

这是我的 webpack 配置:

这是我遇到问题的 React 文件:

我确定我只是缺少一些关于使用某种加载器或其他东西的基本 Webpack 范例,但我无法弄清楚。

我真的很感激任何帮助,因为这已经阻止了我几个小时......


这是我的依赖项:

它可以在没有 Babel 的情况下工作,但我需要 Babel ......

0 投票
0 回答
328 浏览

angular - 延迟加载条纹