File tree Expand file tree Collapse file tree 6 files changed +87
-0
lines changed
Expand file tree Collapse file tree 6 files changed +87
-0
lines changed Original file line number Diff line number Diff line change 1+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+ exports [` EsModules should generate ES6 modules 1` ] = `
4+ "// extracted by mini-css-extract-plugin
5+ export default { \\" test\\ " :\\" MHBvAShXnAxWEC-jxsBd\\ " } ;"
6+ ` ;
Original file line number Diff line number Diff line change 1+ body {
2+ background : red;
3+ }
4+
5+ .test {
6+ color : black;
7+ }
Original file line number Diff line number Diff line change 1+ /* eslint-disable */
2+ import styles from './style.css' ;
Original file line number Diff line number Diff line change 1+ body {
2+ background : red;
3+ }
4+
5+ .test {
6+ color : black;
7+ }
Original file line number Diff line number Diff line change 1+ import Self from '../../../src' ;
2+
3+ module . exports = {
4+ entry : './index.js' ,
5+ module : {
6+ rules : [
7+ {
8+ test : / \. c s s $ / ,
9+ use : [
10+ {
11+ loader : Self . loader ,
12+ options : {
13+ esModules : true ,
14+ } ,
15+ } ,
16+ {
17+ loader : 'css-loader' ,
18+ options : {
19+ modules : true ,
20+ } ,
21+ } ,
22+ ] ,
23+ } ,
24+ ] ,
25+ } ,
26+ plugins : [
27+ new Self ( {
28+ filename : '[name].css' ,
29+ } ) ,
30+ ] ,
31+ } ;
Original file line number Diff line number Diff line change 1+ import path from 'path' ;
2+
3+ import webpack from 'webpack' ;
4+
5+ describe ( 'EsModules' , ( ) => {
6+ it ( 'should generate ES6 modules' , ( done ) => {
7+ const casesDirectory = path . resolve ( __dirname , 'cases' ) ;
8+ const directoryForCase = path . resolve ( casesDirectory , 'esModules' ) ;
9+ // eslint-disable-next-line import/no-dynamic-require, global-require
10+ const webpackConfig = require ( path . resolve (
11+ directoryForCase ,
12+ 'webpack.config.js'
13+ ) ) ;
14+ const compiler = webpack ( {
15+ ...webpackConfig ,
16+ mode : 'development' ,
17+ context : directoryForCase ,
18+ cache : false ,
19+ } ) ;
20+
21+ compiler . run ( ( err1 , stats ) => {
22+ const { modules } = stats . toJson ( ) ;
23+ let foundModule = false ;
24+ modules . forEach ( ( module ) => {
25+ if ( module . name === './style.css' ) {
26+ foundModule = true ;
27+ expect ( module . source ) . toMatchSnapshot ( ) ;
28+ }
29+ } ) ;
30+ expect ( foundModule ) . toBe ( true ) ;
31+ done ( ) ;
32+ } ) ;
33+ } ) ;
34+ } ) ;
You can’t perform that action at this time.
0 commit comments