This repository was archived by the owner on May 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
140 lines (125 loc) · 5.05 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/**
* Copyright 2017 aixigo AG
* Released under the MIT license.
* http://laxarjs.org/license
*/
/* eslint-env node */
const path = require( 'path' );
const WebpackJasmineHtmlRunnerPlugin = require( 'webpack-jasmine-html-runner-plugin' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
module.exports = ( env = {} ) =>
env.browserSpec ?
Object.assign( config( env ), {
entry: WebpackJasmineHtmlRunnerPlugin.entry( './application/widgets/*/spec/*.spec.js' ),
output: {
path: resolve( 'spec-output' ),
publicPath: '/spec-output/',
filename: '[name].bundle.js'
}
} ) :
config( env );
function config( env ) {
const outputPath = 'var/dist/';
return {
devtool: '#source-map',
entry: { 'init': './init.js' },
output: {
path: path.resolve( __dirname, `./${outputPath}` ),
publicPath: outputPath,
filename: '[name].bundle.js',
chunkFilename: '[name].bundle.js'
},
plugins:
[ new ExtractTextPlugin( { filename: '[name].bundle.css' } ) ]
.concat( env.production ? [] : [ new WebpackJasmineHtmlRunnerPlugin() ] ),
resolve: {
descriptionFiles: [ 'package.json' ],
modules: [
path.resolve( './lib' ),
path.resolve( './node_modules' )
],
extensions: [ '.js', '.jsx' ],
alias: {
'polyfills': path.resolve( './node_modules/laxar/dist/polyfills.js' ),
'laxar-uikit': path.resolve( './node_modules/laxar-uikit' ),
'default.theme': path.resolve( './node_modules/laxar-uikit/themes/default.theme' ),
'grid': path.resolve( './lib/laxar-developer-tools/grid.js' ),
'widget-outline': path.resolve( './lib/laxar-developer-tools/widget-outline.js' )
}
},
module: {
rules: [
{
test: /\.(js)$/,
exclude: resolve( 'node_modules' ),
use: 'babel-loader'
},
{
test: /.spec.(jsx?)$/,
exclude: resolve( 'node_modules' ),
loader: 'laxar-mocks/spec-loader'
},
{
test: /.jsx$/,
exclude: resolve( 'node_modules' ),
loader: 'babel-loader'
},
{ // load styles, images and fonts with the file-loader
// (out-of-bundle in var/build/assets/)
test: /\.(gif|jpe?g|png|ttf|woff2?|svg|eot|otf)(\?.*)?$/,
loader: 'file-loader',
options: {
name: 'assets/[name].[ext]'
}
},
{ // ... after optimizing graphics with the image-loader ...
test: /\.(gif|jpe?g|png|svg)$/,
loader: 'img-loader?progressive=true'
},
{ // ... and resolving CSS url()s with the css loader
// (extract-loader extracts the CSS string from the JS module returned by the css-loader)
test: /\.(css|s[ac]ss)$/,
loader: ExtractTextPlugin.extract( {
fallback: 'style-loader',
use: env.production ? 'css-loader' : 'css-loader?sourceMap',
publicPath: ''
} )
},
{ // load scss files by precompiling with the sass-loader
test: /\/default.theme\/.*\.s[ac]ss$/,
loader: 'sass-loader',
options: {
sourceMap: true,
includePaths: [
'laxar-uikit/themes/default.theme/scss',
'laxar-uikit/scss',
resolve( 'node_modules/bootstrap-sass/assets/stylesheets' ),
resolve( 'node_modules' ),
resolve( 'node_modules/laxar-uikit/scss' ),
resolve( 'node_modules/laxar-uikit/themes/default.theme/scss' )
].map( p => path.resolve( __dirname, p ) )
}
},
{ // load function as grid module
// grid.js must be a valid content script for extension
test: require.resolve( './lib/laxar-developer-tools/grid.js' ),
use: [ {
loader: 'exports-loader',
options: 'axDeveloperToolsToggleGrid'
} ]
},
{ // load function as widget-outline module
// widget-outline.js must be a valid content script for extension
test: require.resolve( './lib/laxar-developer-tools/widget-outline.js' ),
use: [ {
loader: 'exports-loader',
options: 'axDeveloperToolsToggleWidgetOutline'
} ]
}
]
}
};
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
function resolve( p ) { return path.resolve( __dirname, p ); }