PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 4.9.3
Jetpack – WP Security, Backup, Speed, & Growth v4.9.3
16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
jetpack / webpack.config.js

webpack.config.js in Jetpack – WP Security, Backup, Speed, & Growth 4.9.3, at webpack.config.js

121 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 require( 'es6-promise' ).polyfill();
2
3 var path = require( 'path' );
4 var webpack = require( 'webpack' );
5 var fs = require('fs');
6 var NODE_ENV = process.env.NODE_ENV || 'development';
7 var ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
8
9 var IS_HOT_UPDATE = ( process.env.NODE_ENV !== 'production' );
10
11 var jsLoader = IS_HOT_UPDATE ?
12 [ require.resolve( 'react-hot-loader' ), require.resolve( 'babel-loader' ), require.resolve( 'eslint-loader' ) ] :
13 [ require.resolve( 'babel-loader' ), require.resolve( "eslint-loader" ) ];
14
15 var cssLoader = IS_HOT_UPDATE ?
16 'style!css?sourceMap!autoprefixer!' :
17 ExtractTextPlugin.extract( 'css?sourceMap!autoprefixer!' );
18
19 // This file is written in ES5 because it is run via Node.js and is not transpiled by babel. We want to support various versions of node, so it is best to not use any ES6 features even if newer versions support ES6 features out of the box.
20 var webpackConfig = {
21
22 // Entry points point to the javascript module that is used to generate the script file.
23 // The key is used as the name of the script.
24 entry: {
25 admin: './_inc/client/admin.js',
26 static: './_inc/client/static.jsx'
27 },
28 output: {
29 path: path.join( __dirname, '_inc/build' ),
30 filename: "[name].js"
31 },
32 module: {
33
34 // Webpack loaders are applied when a resource is matches the test case
35 loaders: [
36 {
37 test: /\.jsx?$/,
38 loaders: jsLoader,
39
40 // include both typical npm-linked locations and default module locations to handle both cases
41 include: [
42 path.join( __dirname, 'test' ),
43 path.join( __dirname, '_inc/client' ),
44 fs.realpathSync( path.join( __dirname, './node_modules/@automattic/dops-components/client' ) ),
45 path.join( __dirname, './node_modules/@automattic/dops-components/client' )
46 ]
47 },
48 {
49 test: /\.json$/,
50 loader: 'json-loader'
51 },
52 {
53 test: /\.css$/,
54 loader: cssLoader
55 },
56 {
57 test: /\.html$/,
58 loader: 'html-loader'
59 },
60 {
61 test: /\.scss$/,
62 loader: ExtractTextPlugin.extract( 'style-loader', 'css!sass' )
63 },
64 {
65 test: /\.svg/,
66 loader: 'url-loader'
67 }
68 ]
69 },
70 resolve: {
71 extensions: [ '', '.js', '.jsx' ],
72 alias: {
73 "react": path.join(__dirname, "/node_modules/react")
74 },
75 root: [
76 path.resolve( __dirname, '_inc/client' ),
77 fs.realpathSync( path.join(__dirname, 'node_modules/@automattic/dops-components/client') )
78 ]
79 },
80 resolveLoader: {
81 root: path.join( __dirname, 'node_modules' )
82 },
83 node: {
84 fs: "empty",
85 process: true
86 },
87 eslint: {
88 configFile: path.join(__dirname, '.eslintrc'),
89 quiet: true
90 },
91 plugins: [
92 new webpack.DefinePlugin({
93
94 // NODE_ENV is used inside React to enable/disable features that should only
95 // be used in development
96 'process.env': {
97 NODE_ENV: JSON.stringify( NODE_ENV )
98 }
99 }),
100 new ExtractTextPlugin( '[name].dops-style.css' )
101 ],
102 externals: {
103 'react/addons': true,
104 'react/lib/ExecutionEnvironment': true,
105 'react/lib/ReactContext': true,
106 jsdom: 'window'
107 }
108 };
109
110 if ( NODE_ENV === 'production' ) {
111
112 webpack.DefinePlugin( {
113 "process.env": {
114 // This has effect on the react lib size
115 "NODE_ENV": JSON.stringify(process.env.NODE_ENV) // TODO switch depending on actual environment
116 }
117 } );
118 }
119
120 module.exports = webpackConfig;
121