How to use @wordpress/scripts - 10 common examples

To help you get started, we’ve selected a few @wordpress/scripts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ampproject / amp-wp / qa-tester / webpack.config.js View on Github external
...defaultConfig.module,
		rules: [
			...defaultConfig.module.rules,
			{
				test: /\.css$/,
				use: [
					// prettier-ignore
					MiniCssExtractPlugin.loader,
					'css-loader',
					'postcss-loader',
				],
			},
		],
	},
	plugins: [
		...defaultConfig.plugins,
		new MiniCssExtractPlugin( {
			filename: '../css/[name]-compiled.css',
		} ),
		new RtlCssPlugin( {
			filename: '../css/[name]-compiled-rtl.css',
		} ),
	],
};

const adminBar = {
	...defaultConfig,
	...sharedConfig,
	entry: {
		'admin-bar': [ './assets/src/js/admin-bar/index.js' ],
	},
	plugins: [
github ampproject / amp-wp / bin / local-env / run-e2e-tests.js View on Github external
const testsToIgnore = [];

	if ( semver.gte( semver.clean( wpVersion ), '5.3.0' ) ) {
		// Ignore tests that are not to be run in WP >= 5.3.0.
		testsToIgnore.push( 'AMP Settings Screen should not allow AMP Stories to be enabled when Gutenberg is not active' );
	}

	const testNamePatterns = testsToIgnore.map( ( testName ) => {
		return `--testNamePattern='^(?!${ testName }).*$'`;
	} );

	const cmdArgs = [ ...suppliedArgs, ...testNamePatterns ];

	// Run E2E tests.
	spawnScript( 'test-e2e', cmdArgs );
} );
github insideout10 / wordlift-plugin / src-js / webpack / webpack.config.js View on Github external
},
  /*
   * Give precedence to our node_modules folder when resolving the same module.
   *
   * This solves duplicate issues with styled-components.
   *
   * @see https://www.styled-components.com/docs/faqs#why-am-i-getting-a-warning-about-several-instances-of-module-on-the-page
   */
  // resolve: {
  //   modules: [path.resolve(__dirname, "node_modules"), "node_modules"]
  // },
  devtool: "eval-source-map",
  module: {
    ...defaultConfig.module,
    rules: [
      ...defaultConfig.module.rules,
      {
        test: /\.css$/i,
        use: [MiniCssExtractPlugin.loader, "css-loader"]
      },
      {
        test: /\.s[ac]ss$/i,
        use: [
          // We use the MiniCssExtractPlugin for both production and development
          // since development happens inside of WordPress which loads the css
          // files anyway (using the enqueue_scripts hook).
          //
          // @see https://webpack.js.org/loaders/sass-loader/#extracting-style-sheets
          MiniCssExtractPlugin.loader,
          "css-loader",
          "sass-loader" // compiles Sass to CSS, using Node Sass by default
        ]
github GraphQLAPI / graphql-api-for-wp / blocks / cache-control / webpack.config.js View on Github external
// langs.forEach( lang => config.entry[`docs-${ lang }`] = path.resolve( process.cwd(), `docs/${ lang }`, 'index.js' ) )
// ---------------------------------------------

// ---------------------------------------------
// Uncomment for webpack v5, to not duplicate the content of the docs inside build/index.js
// config.entry.index = {
// 	import: path.resolve( process.cwd(), 'src', 'index.js' ),
// 	dependOn: 'docs'
// }
// config.entry.docs = langs.map( lang => `docs-${ lang }` )
// ---------------------------------------------

/**
 * Add support for additional file types
 */
config.module.rules.push(
	/**
	 * Markdown
	 */
	{
		test: /\.md$/,
		use: [
			{
				loader: "html-loader"
			},
			{
				loader: "markdown-loader"
			}
		]
	}
);
github xwp / wp-foo-bar / webpack.config.js View on Github external
sourceMap: false,
				cache: true,
				terserOptions: {
					output: {
						comments: /translators:/i,
					},
				},
				extractComments: false,
			} ),
			new OptimizeCSSAssetsPlugin( {} ),
		],
	},
	module: {
		...defaultConfig.module,
		rules: [
			...defaultConfig.module.rules,
			{
				test: /\.css$/,
				use: [
					// prettier-ignore
					MiniCssExtractPlugin.loader,
					'css-loader',
					'postcss-loader',
				],
			},
		],
	},
	plugins: [
		...defaultConfig.plugins,
		new MiniCssExtractPlugin( {
			filename: '../css/[name]-compiled.css',
		} ),
github xwp / wp-foo-bar / webpack.config.js View on Github external
...defaultConfig.module,
		rules: [
			...defaultConfig.module.rules,
			{
				test: /\.css$/,
				use: [
					// prettier-ignore
					MiniCssExtractPlugin.loader,
					'css-loader',
					'postcss-loader',
				],
			},
		],
	},
	plugins: [
		...defaultConfig.plugins,
		new MiniCssExtractPlugin( {
			filename: '../css/[name]-compiled.css',
		} ),
		new RtlCssPlugin( {
			filename: '../css/[name]-compiled-rtl.css',
		} ),
	],
};

const blockEditor = {
	...defaultConfig,
	...sharedConfig,
	entry: {
		'block-editor': [
			'./assets/src/block-editor/index.js',
			'./assets/css/src/block-editor.css',
github insideout10 / wordlift-plugin / src-js / webpack / webpack.config.js View on Github external
// @see https://webpack.js.org/loaders/sass-loader/#extracting-style-sheets
          MiniCssExtractPlugin.loader,
          "css-loader",
          "sass-loader" // compiles Sass to CSS, using Node Sass by default
        ]
      },
      {
        test: /.svg$/,
        use: {
          loader: "svg-react-loader"
        }
      }
    ]
  },
  plugins: [
    ...defaultConfig.plugins,
    // @see https://webpack.js.org/loaders/sass-loader/#extracting-style-sheets
    new MiniCssExtractPlugin({
      filename: "[name].css"
    })
  ],
  externals: {
    ...defaultConfig.externals,
    backbone: "Backbone"
  }
};

// Create the full configuration for files that will include all the dependencies to keep WordPress pre 5.0.0 compatibility.
const webpackConfigFull = { ...webpackConfig };
// Remove the `DependencyExtractionWebpackPlugin`.
webpackConfigFull.plugins = webpackConfig.plugins.filter(
  entry => !(entry instanceof DependencyExtractionWebpackPlugin)
github GraphQLAPI / graphql-api-for-wp / editor-scripts / endpoint-editor-components / webpack.config.js View on Github external
{
				loader: "markdown-loader"
			}
		]
	}
);

/**
 * Because the block and the package have their own webpack configuration,
 * they must provide a unique name for the global scope (which is used to lazy-load chunks),
 * otherwise it throws a JS error when loading blocks compiled with `npm run build`
 * @see https://github.com/WordPress/gutenberg/issues/23607
 * @see https://webpack.js.org/configuration/output/#outputjsonpfunction
 */
// ------------------------------------------------------
config.output.jsonpFunction = 'webpackJsonpGraphQLAPIEndpointEditorComponents';
// ------------------------------------------------------

module.exports = config;
github GraphQLAPI / graphql-api-for-wp / editor-scripts / persisted-query-editor-components / webpack.config.js View on Github external
{
				loader: "markdown-loader"
			}
		]
	}
);

/**
 * Because the block and the package have their own webpack configuration,
 * they must provide a unique name for the global scope (which is used to lazy-load chunks),
 * otherwise it throws a JS error when loading blocks compiled with `npm run build`
 * @see https://github.com/WordPress/gutenberg/issues/23607
 * @see https://webpack.js.org/configuration/output/#outputjsonpfunction
 */
// ------------------------------------------------------
config.output.jsonpFunction = 'webpackJsonpGraphQLAPIPersistedQueryEditorComponents';
// ------------------------------------------------------

module.exports = config;
github GraphQLAPI / graphql-api-for-wp / editor-scripts / endpoint-editor-components / webpack.config.js View on Github external
const path = require( 'path' );

const config = require( '@wordpress/scripts/config/webpack.config' );

/**
 * Documentation in different languages
 */
langs = ['en', 'es']
langs.forEach( lang => config.entry[`docs-${ lang }`] = path.resolve( process.cwd(), `docs/${ lang }`, 'index.js' ) )
config.resolve.alias['@docs'] = path.resolve(process.cwd(), 'docs/')

// ---------------------------------------------
// Uncomment for webpack v5, to not duplicate the content of the docs inside build/index.js
// config.entry.index = {
// 	import: path.resolve( process.cwd(), 'src', 'index.js' ),
// 	dependOn: 'docs'
// }
// config.entry.docs = langs.map( lang => `docs-${ lang }` )
// ---------------------------------------------

/**
 * Add support for additional file types
 */
config.module.rules.push(
	/**
	 * Markdown