-
Notifications
You must be signed in to change notification settings - Fork 4
/
webpack.config.js
49 lines (46 loc) · 1.45 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const defaultConfig = require( '@wordpress/scripts/config/webpack.config' );
const WooCommerceDependencyExtractionWebpackPlugin = require( '@woocommerce/dependency-extraction-webpack-plugin' );
const I18nLoaderWebpackPlugin = require( '@automattic/i18n-loader-webpack-plugin' );
const path = require( 'path' );
// Import variables and mixins from the stylesheets directory so they can be used in all scss files.
defaultConfig.module.rules.push( {
test: /\.(sc|sa)ss$/,
use: [
{
loader: 'sass-loader',
options: {
sassOptions: {
includePaths: [
path.resolve( __dirname, 'src/stylesheets' ),
],
},
// Prepends Sass/SCSS code before the actual entry file
additionalData: ( content ) => {
return (
'@import "_variables"; ' +
'@import "_mixins"; ' +
content
);
},
},
},
],
} );
// Disable exports mangling to ensure the exported i18n loader method name `loadTranslations` is preserved,
// as it's being referred by name in the I18nLoaderWebpackPlugin's runtime template.
defaultConfig.optimization.mangleExports = false;
module.exports = {
...defaultConfig,
plugins: [
...defaultConfig.plugins.filter(
( plugin ) =>
plugin.constructor.name !== 'DependencyExtractionWebpackPlugin'
),
new WooCommerceDependencyExtractionWebpackPlugin(),
new I18nLoaderWebpackPlugin( {
textdomain: 'wc-calypso-bridge',
loaderModule: './src/i18n-loader',
loaderMethod: 'loadTranslations',
} ),
],
};