mirror of
				https://github.com/strapi/strapi.git
				synced 2025-10-31 01:47:13 +00:00 
			
		
		
		
	
		
			
	
	
		
			97 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
		
		
			
		
	
	
			97 lines
		
	
	
		
			2.5 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
|   | /** | ||
|  |  * TEST WEBPACK CONFIGURATION | ||
|  |  */ | ||
|  | 
 | ||
|  | const path = require('path'); | ||
|  | 
 | ||
|  | const webpack = require('webpack'); | ||
|  | 
 | ||
|  | const modules = [ | ||
|  |   'src', | ||
|  |   'node_modules', | ||
|  |   'node_modules/strapi-helper-plugin/lib/src', | ||
|  |   'node_modules/strapi-helper-plugin/node_modules', | ||
|  | ]; | ||
|  | 
 | ||
|  | module.exports = { | ||
|  |   devtool: 'inline-source-map', | ||
|  |   isparta: { | ||
|  |     babel: { | ||
|  |       presets: ['es2015', 'react', 'stage-0'], | ||
|  |     }, | ||
|  |   }, | ||
|  |   module: { | ||
|  |     // Some libraries don't like being run through babel.
 | ||
|  |     // If they gripe, put them here.
 | ||
|  |     noParse: [ | ||
|  |       /build/, | ||
|  |       /node_modules(\\|\/)sinon/, | ||
|  |       /node_modules(\\|\/)acorn/, | ||
|  |     ], | ||
|  |     preLoaders: [ | ||
|  |       { test: /\.js$/, | ||
|  |         loader: 'isparta-loader', | ||
|  |         include: path.resolve('src/'), | ||
|  |       }, | ||
|  |     ], | ||
|  |     loaders: [ | ||
|  |       { test: /\.json$/, loader: 'json-loader' }, | ||
|  |       { test: /\.css$/, loader: 'null-loader' }, | ||
|  |       { test: /\.scss$/, loader: ['style-loader', 'css-loader', 'sass-loader'] }, | ||
|  | 
 | ||
|  |       // sinon.js--aliased for enzyme--expects/requires global vars.
 | ||
|  |       // imports-loader allows for global vars to be injected into the module.
 | ||
|  |       // See https://github.com/webpack/webpack/issues/304
 | ||
|  |       { test: /sinon(\\|\/)pkg(\\|\/)sinon\.js/, | ||
|  |         loader: 'imports?define=>false,require=>false', | ||
|  |       }, | ||
|  |       { test: /\.js$/, | ||
|  |         loader: 'babel-loader', | ||
|  |         exclude: [/node_modules/], | ||
|  |       }, | ||
|  |       { test: /\.jpe?g$|\.gif$|\.png$|\.svg$/i, | ||
|  |         loader: 'null-loader', | ||
|  |       }, | ||
|  |     ], | ||
|  |   }, | ||
|  | 
 | ||
|  |   plugins: [ | ||
|  | 
 | ||
|  |     // Always expose NODE_ENV to webpack, in order to use `process.env.NODE_ENV`
 | ||
|  |     // inside your code for any environment checks; UglifyJS will automatically
 | ||
|  |     // drop any unreachable code.
 | ||
|  |     new webpack.DefinePlugin({ | ||
|  |       'process.env': { | ||
|  |         NODE_ENV: JSON.stringify(process.env.NODE_ENV), | ||
|  |       }, | ||
|  |     })], | ||
|  | 
 | ||
|  |   // Some node_modules pull in Node-specific dependencies.
 | ||
|  |   // Since we're running in a browser we have to stub them out. See:
 | ||
|  |   // https://webpack.github.io/docs/configuration.html#node
 | ||
|  |   // https://github.com/webpack/node-libs-browser/tree/master/mock
 | ||
|  |   // https://github.com/webpack/jade-loader/issues/8#issuecomment-55568520
 | ||
|  |   node: { | ||
|  |     fs: 'empty', | ||
|  |     child_process: 'empty', | ||
|  |     net: 'empty', | ||
|  |     tls: 'empty', | ||
|  |   }, | ||
|  | 
 | ||
|  |   // required for enzyme to work properly
 | ||
|  |   externals: { | ||
|  |     jsdom: 'window', | ||
|  |     'react/addons': true, | ||
|  |     'react/lib/ExecutionEnvironment': true, | ||
|  |     'react/lib/ReactContext': 'window', | ||
|  |   }, | ||
|  |   resolve: { | ||
|  |     modulesDirectories: modules, | ||
|  |     modules, | ||
|  |     alias: { | ||
|  |       // required for enzyme to work properly
 | ||
|  |       sinon: 'sinon/pkg/sinon', | ||
|  |     }, | ||
|  |   }, | ||
|  | }; |