@@ -3,6 +3,8 @@ const webpack = require('webpack');
33const path = require ( 'path' ) ;
44const fs = require ( 'fs' ) ;
55
6+ const VueLoaderPlugin = require ( 'vue-loader/lib/plugin' ) ;
7+
68const toAbsolutePath = require ( './utils' ) . toAbsolutePath ;
79const generateConvertFile = require ( './convertFileGenerator' ) ;
810
@@ -11,7 +13,6 @@ const fileToDelete = [];
1113// ----------------------------------------------------------------------------
1214
1315function buildWebpackConfiguration ( name , basepath , outputPath , compress ) {
14- const plugins = [ ] ;
1516 const entry = path . join ( basepath , 'index.js' ) ;
1617 const simputNodeModules = path . join ( __dirname , '../../node_modules' ) ;
1718 return {
@@ -21,7 +22,9 @@ function buildWebpackConfiguration(name, basepath, outputPath, compress) {
2122 path : outputPath ,
2223 filename : `${ name } .js` ,
2324 } ,
24- plugins,
25+ plugins : [
26+ new VueLoaderPlugin ( ) ,
27+ ] ,
2528 resolveLoader : {
2629 modules : [ simputNodeModules ] ,
2730 } ,
@@ -33,16 +36,31 @@ function buildWebpackConfiguration(name, basepath, outputPath, compress) {
3336 test : entry ,
3437 loader : `expose-loader?Simput.types.${ name } ` ,
3538 } ,
36- { test : / \. ( p n g | j p g ) $ / , use : 'url-loader?limit=81920' } ,
37- { test : / \. h t m l $ / , loader : 'html-loader' } ,
39+ { test : / \. ( p n g | j p g | s v g ) $ / , use : 'url-loader?limit=81920' } ,
3840 {
3941 test : / \. c s s $ / ,
42+ exclude : / n o d e _ m o d u l e s / ,
43+ use : [
44+ 'vue-style-loader' ,
45+ {
46+ loader : 'css-loader' ,
47+ options : {
48+ modules : true ,
49+ localIdentName : '[folder]-[local]-[sha512:hash:base32:5]' ,
50+ } ,
51+ } ,
52+ ] ,
53+ } ,
54+ {
55+ test : / \. c s s $ / ,
56+ include : / n o d e _ m o d u l e s / ,
4057 use : [ 'style-loader' , 'css-loader' , 'postcss-loader' ] ,
4158 } ,
4259 { test : / \. c j s o n $ / , loader : 'hson-loader' } ,
4360 { test : / \. h s o n $ / , loader : 'hson-loader' } ,
4461 { test : / \. j a d e $ / i, loader : 'jade-loader' } ,
4562 { test : / \. h b s $ / i, loader : 'handlebars-loader' } ,
63+ { test : / \. v u e $ / , loader : 'vue-loader' } ,
4664 {
4765 test : / \. j s $ / ,
4866 use : [
@@ -64,8 +82,31 @@ function buildWebpackConfiguration(name, basepath, outputPath, compress) {
6482 } ,
6583 ] ,
6684 } ,
85+ // vtk.js rules
86+ {
87+ test : / \. g l s l $ / i,
88+ include : / n o d e _ m o d u l e s ( \/ | \\ ) v t k \. j s ( \/ | \\ ) / ,
89+ loader : 'shader-loader' ,
90+ } ,
91+ {
92+ test : / \. s v g $ / ,
93+ include : / n o d e _ m o d u l e s ( \/ | \\ ) v t k \. j s ( \/ | \\ ) / ,
94+ use : [
95+ { loader : 'raw-loader' } ,
96+ ] ,
97+ } ,
6798 ] ,
6899 } ,
100+ resolve : {
101+ extensions : [ '.js' , '.vue' , '.json' ] ,
102+ alias : {
103+ vue$ : 'vue/dist/vue.esm.js' ,
104+ } ,
105+ } ,
106+ externals : {
107+ 'vue' : 'Vue' ,
108+ 'vuex' : 'Vuex' ,
109+ } ,
69110 } ;
70111}
71112
@@ -170,9 +211,16 @@ module.exports = function compile(
170211 schema = schema . replace ( 'TYPE' , modelType ) ;
171212 schema = schema . replace ( 'LANG' , lang ) ;
172213
214+ let requireWidgets = '' ;
215+
216+ if ( shell . test ( '-f' , path . join ( directory , 'widgets' , 'index.js' ) ) ) {
217+ requireWidgets = 'require("./widgets/index.js")' ;
218+ }
219+
173220 fs . writeFileSync (
174221 path . join ( directory , 'index.js' ) ,
175- `module.exports = ${ schema } `
222+ `${ requireWidgets } ;
223+ module.exports = ${ schema } `
176224 ) ;
177225 fileToDelete . push ( path . join ( directory , 'index.js' ) ) ;
178226 webpack (
0 commit comments