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
Expand file tree
/
Copy pathwebpack.config.js
More file actions
100 lines (91 loc) · 3.3 KB
/
webpack.config.js
File metadata and controls
100 lines (91 loc) · 3.3 KB
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
/**
* Copyright 2017 aixigo AG
* Released under the MIT license
* www.laxarjs.org
*/
const path = require( 'path' );
const ExtractTextPlugin = require( 'extract-text-webpack-plugin' );
const WebpackJasmineHtmlRunnerPlugin = require( 'webpack-jasmine-html-runner-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 = env.production ? 'dist/' : 'build/';
return {
devtool: '#source-map',
entry: {
'init': './init.js'
},
output: {
path: path.resolve( __dirname, outputPath ),
publicPath: outputPath,
filename: env.production ? '[name].bundle.min.js' : '[name].bundle.js'
},
plugins: [ new ExtractTextPlugin( { filename: '[name].bundle.css' } ) ]
.concat( env.production ? [] : [ new WebpackJasmineHtmlRunnerPlugin() ] ),
resolve: {
modules: [ path.resolve( __dirname, 'node_modules' ) ],
extensions: [ '.js', '.jsx', '.vue' ],
alias: {
'default.theme': 'laxar-uikit/themes/default.theme'
}
},
module: {
rules: [
{
test: /.js$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /.spec.js$/,
exclude: /node_modules/,
loader: 'laxar-mocks/spec-loader'
},
{ // load styles, images and fonts with the file-loader
// (out-of-bundle in build/assets/)
test: /\.(gif|jpe?g|png|ttf|woff2?|svg|eot|otf)(\?.*)?$/,
loader: 'file-loader',
options: {
name: env.production ? 'assets/[name]-[sha1:hash:8].[ext]' : 'assets/[path]-[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: ''
} )
},
{
test: /[/]default[.]theme[/].*[.]s[ac]ss$/,
loader: 'sass-loader',
options: require( 'laxar-uikit/themes/default.theme/sass-options' )
},
{
test: /.jsx$/,
exclude: /node_modules/,
loader: 'babel-loader'
},
{
test: /.vue$/,
loader: 'vue-loader'
}
]
}
};
}