-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathwebpack.config.js
More file actions
83 lines (79 loc) · 3.47 KB
/
webpack.config.js
File metadata and controls
83 lines (79 loc) · 3.47 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
'use strict';
//requires
const pkg = require('./package'),
bower = require('./bower'),
path = require('path'),
semver = require('semver'),
webpack = require('webpack'),
generateJsonPlugin = require('generate-json-webpack-plugin'),
extractTextPlugin = require('extract-text-webpack-plugin'),
copyWebpackPlugin = require('copy-webpack-plugin');
//variables
const argv = process.argv,
isProduction = argv.indexOf('-p') != -1,
filename = 'angular-screenshot' + (isProduction ? '.min' : ''),
increase = (argv.filter(arg => arg.match(/^increase=.+$/))[0] || '').replace('increase=', ''),
directivePath = path.resolve(__dirname, './src/angular-screenshot.js'),
stylePath = path.resolve(__dirname, './src/stylesheets/index.css'),
buildPath = path.resolve(__dirname, './build');
//sync info with package.json
pkg.version = increase ? semver.inc(pkg.version, increase) : pkg.version;
['name', 'version', 'description', 'homepage', 'license', 'keywords', 'dependencies'].forEach(field => bower[field] = pkg[field]);
module.exports = {
entry: [
directivePath,
stylePath
],
output: {
path: buildPath,
filename: filename + '.js'
},
externals: Object.keys(pkg.dependencies),
resolve: {
extensions: ['.js', '.scss']
},
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loaders: ['babel-loader?presets[]=es2015']
}, {
test: /\.css$/,
exclude: /(node_modules|bower_components)/,
loader: extractTextPlugin.extract({
use: [{
loader: 'css-loader?importLoaders=1'
}, {
loader: 'postcss-loader',
options: {
plugins: () => [
require('postcss-import')({}),
require('postcss-cssnext')({
browsers: ['last 2 versions', '> 5%']
})
]
}
}], fallback: 'style-loader'
})
}]
},
plugins: [
new extractTextPlugin(filename + '.css'),
new webpack.BannerPlugin('Angular Screenshot - v' + pkg.version + ' - ' + pkg.homepage + ' - (c) 2017 weihanchen - ' + pkg.license),
new generateJsonPlugin('../bower.json', bower, undefined, 2),
new generateJsonPlugin('../package.json', pkg, undefined, 2),
new copyWebpackPlugin([
{ from: 'node_modules/angular/angular.min.js', to: '../examples/js/plugins' },
{ from: 'node_modules/jquery/dist/jquery.min.js', to: '../examples/js/plugins' },
{ from: 'node_modules/bootstrap/dist/css/bootstrap.min.css', to: '../examples/css/plugins' },
{ from: 'node_modules/bootstrap/dist/js/bootstrap.min.js', to: '../examples/js/plugins' },
{ from: 'node_modules/bootstrap/dist/fonts', to: '../examples/css/fonts' },
{ from: 'node_modules/font-awesome/fonts', to: '../examples/css/fonts' },
{ from: 'node_modules/font-awesome/css/font-awesome.min.css', to: '../examples/css/plugins' },
{ from: 'node_modules/highlightjs/styles/default.css', to: '../examples/css/plugins' },
{ from: 'node_modules/highlightjs/highlight.pack.min.js', to: '../examples/js/plugins' },
{ from: 'node_modules/bootstrap-material-design/dist/css/bootstrap-material-design.min.css', to: '../examples/css/plugins' },
{ from: 'node_modules/bootstrap-material-design/dist/css/ripples.min.css', to: '../examples/css/plugins' }
])
]
};