wix-style-react
Version:
wix-style-react
47 lines (45 loc) • 1.59 kB
JavaScript
;
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.decorateNextJsWebpackConfig = void 0;
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var {
StylableWebpackPlugin,
applyWebpackConfigStylableExcludes
} = require('@stylable/webpack-plugin');
var StylableOptimizer = require('@stylable/optimizer').StylableOptimizer;
var stylableOptimizer = new StylableOptimizer();
var packages = new Set(['wix-style-react']);
var decorateNextJsWebpackConfig = (config, _ref) => {
var {
isServer
} = _ref;
// causes provided packages to be bundled (not external)
if (isServer) {
var nextExternals = config.externals[0];
config.externals = [(/*#__PURE__*/function () {
var _ref2 = (0, _asyncToGenerator2.default)(function* (ctx) {
// @ts-ignore
for (var pack of packages) {
if (ctx.request.startsWith(pack)) {
return false;
}
}
return nextExternals(ctx);
});
return function (_x) {
return _ref2.apply(this, arguments);
};
}())];
}
// excludes other configs from attempting to handle stylable files
applyWebpackConfigStylableExcludes(config);
config.plugins.push(new StylableWebpackPlugin({
filterAssets: () => false,
filename: 'static/css/stylable.[contenthash].css',
optimizer: stylableOptimizer
}));
return config;
};
exports.decorateNextJsWebpackConfig = decorateNextJsWebpackConfig;
//# sourceMappingURL=index.js.map