1
+ const glob = require ( 'glob' )
2
+ const path = require ( 'path' )
3
+
4
+ const MiniCssExtractPlugin = require ( 'mini-css-extract-plugin' )
5
+ const jsPath = path . join ( __dirname , 'src' , )
6
+ const packageJsPath = path . join ( __dirname , 'fuel' , 'packages' )
7
+ const cssPath = path . join ( __dirname , 'src' , 'css' )
8
+ const componentCssPath = path . join ( __dirname , 'src' , 'components' )
9
+
10
+ const entry = { }
11
+ // Webpack Entry Point Registration Overview
12
+ // Create object with:
13
+ // Key = output name, Value = source sass file
14
+ // for every scss file in the cssPath directory
15
+ // EX: { 'css/<filename>.css' : './src/css/filename.scss', ...}
16
+
17
+
18
+ // SASS/CSS webpack entry point registration
19
+ glob . sync ( path . join ( cssPath , '*.scss' ) ) . forEach ( file => {
20
+ entry [ 'css/' + path . basename ( file , '.scss' ) ] = file
21
+ } )
22
+
23
+ glob . sync ( path . join ( componentCssPath , '*.scss' ) ) . forEach ( file => {
24
+ entry [ 'css/' + path . basename ( file , '.scss' ) ] = file
25
+ } )
26
+
27
+ // // JS webpack entry point registration
28
+ // // locates all `js/*.js` files
29
+ glob . sync ( path . join ( jsPath , '*.js' ) ) . map ( file => {
30
+ entry [ 'js/' + path . basename ( file , '.js' ) ] = file
31
+ } )
32
+
33
+ // some packages (like the reactified materia-theme-ucf) have js that needs to be added to webpack
34
+ glob . sync ( path . join ( packageJsPath , '**/*.js' ) ) . map ( file => {
35
+ entry [ 'js/' + path . basename ( file , '.js' ) ] = file
36
+ } )
37
+
38
+ module . exports = {
39
+ mode : 'production' ,
40
+ entry,
41
+ output : {
42
+ path : path . join ( __dirname , 'public/dist/' ) ,
43
+ filename : '[name].js' ,
44
+ clean : true
45
+ } ,
46
+ module : {
47
+ rules : [
48
+ {
49
+ test : / \. ( j s | j s x ) $ / ,
50
+ exclude : / n o d e _ m o d u l e s / ,
51
+ use : {
52
+ loader : 'babel-loader'
53
+ }
54
+ } ,
55
+ {
56
+ test : / \. s ? c s s $ / ,
57
+ use : [
58
+ MiniCssExtractPlugin . loader ,
59
+ {
60
+ loader : 'css-loader' ,
61
+ options : {
62
+ url : false
63
+ }
64
+ } ,
65
+ 'sass-loader'
66
+ ]
67
+ } ,
68
+ ]
69
+ } ,
70
+ plugins : [
71
+ new MiniCssExtractPlugin ( {
72
+ filename : "[name].css"
73
+ } )
74
+ ] ,
75
+ resolve : {
76
+ extensions : [ '.js' , '.jsx' ] ,
77
+ }
78
+ // externals: {
79
+ // react: 'React',
80
+ // 'react-dom': 'ReactDOM'
81
+ // }
82
+ }
0 commit comments