maurya-scripts
Version:
maurya-scripts compiles elements, menu etc and distributes it with the maurya-editor
129 lines • 5.64 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.desginElementWebpackConfig = void 0;
const path = require("path");
const postcssNormalize = require("postcss-normalize");
const cssRegex = /\.css$/;
const cssModuleRegex = /\.module\.css$/;
const shouldUseSourceMap = false;
// common function to get style loaders
const getStyleLoaders = (cssOptions) => {
const loaders = [
path.resolve("node_modules", "style-loader"),
{
loader: path.resolve("node_modules", "css-loader"),
options: cssOptions,
},
{
// Options for PostCSS as we reference these options twice
// Adds vendor prefixing based on your specified browser support in
// package.json
loader: path.resolve("node_modules", "postcss-loader"),
options: {
postcssOptions: {
// Necessary for external CSS imports to work
// https://github.com/facebook/create-react-app/issues/2677
ident: "postcss",
plugins: () => [
require("postcss-flexbugs-fixes"),
require("postcss-preset-env")({
autoprefixer: {
flexbox: "no-2009",
},
stage: 3,
}),
// Adds PostCSS Normalize as the reset css with default options,
// so that it honors browserslist config in package.json
// which in turn let's users customize the target behavior as per their needs.
postcssNormalize(),
],
},
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
},
},
].filter(Boolean);
return loaders;
};
const isEnvDevelopment = true;
const isEnvProduction = !isEnvDevelopment;
process.env.NODE_ENV = "development";
const desginElementWebpackConfig = (entry, workDir) => {
return {
entry: path.resolve(entry),
output: {
filename: "bundle.js",
path: path.resolve("build"),
},
target: "web",
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.(js|mjs|jsx|ts|tsx)$/,
include: [
path.resolve(workDir, "src"),
path.resolve(workDir, "node_modules", "maurya-editor-web"),
],
use: {
loader: "babel-loader",
options: {
customize: path.resolve("node_modules", "babel-preset-react-app/webpack-overrides"),
presets: [
[
path.resolve("node_modules", "babel-preset-react-app"),
{
runtime: "classic",
development: true,
},
],
],
// @remove-on-eject-begin
babelrc: false,
configFile: false,
// @remove-on-eject-end
plugins: [
[
path.resolve("node_modules", "babel-plugin-named-asset-import"),
{
loaderMap: {
svg: {
ReactComponent: "@svgr/webpack?-svgo,+titleProp,+ref![path]",
},
},
},
],
].filter(Boolean),
// This is a feature of `babel-loader` for webpack (not Babel itself).
// It enables caching results in ./node_modules/.cache/babel-loader/
// directory for faster rebuilds.
cacheDirectory: true,
// See #6846 for context on why cacheCompression is disabled
cacheCompression: false,
compact: false,
},
},
},
{
test: cssRegex,
exclude: cssModuleRegex,
use: getStyleLoaders({
importLoaders: 1,
sourceMap: isEnvProduction ? shouldUseSourceMap : isEnvDevelopment,
}),
// Don't consider CSS imports dead code even if the
// containing package claims to have no side effects.
// Remove this when webpack adds a warning or an error for this.
// See https://github.com/webpack/webpack/issues/6571
sideEffects: true,
},
],
},
resolve: {
extensions: ["", ".js", ".jsx", ".ts", ".tsx"],
},
externals: {},
context: path.resolve(workDir),
};
};
exports.desginElementWebpackConfig = desginElementWebpackConfig;
//# sourceMappingURL=design-element-webpack.js.map
;