-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
100 lines (98 loc) · 2.71 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
'use strict';
const debug = process.env.NODE_ENV !== "production";
const webpack = require('webpack');
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const extractLESS = new ExtractTextPlugin('styles.css');
module.exports = {
context: __dirname,
devtool: debug ? "inline-sourcemap" : null,
entry: {
// scripts: "./src/index.js",
app: "./src/index.js",
bootstrap: "./src/js/bootstrap.js",
},
output: {
path: path.resolve(__dirname, "dist"),
publicPath: "dist",
filename: "[name].bundle.js"
},
module: {
rules: [{
test: /\.less$/,
use: extractLESS.extract({
fallback: 'style-loader', // Adds CSS to the DOM by injecting a `<style>` tag
use: [{
// Interprets `@import` and `url()` like `import/require()` and will resolve them
loader: "css-loader"
}, {
// Loader for webpack to process CSS with PostCSS
loader: 'postcss-loader',
options: {
plugins: function () { // post css plugins, can be exported to postcss.config.js
return [
require('precss'),
require('autoprefixer')
];
}
}
}, {
// Loads a Less file and compiles it to CSS
loader: "less-loader",
options: {
paths: [ path.resolve(__dirname, "node_modules/bootstrap-less") ]
}
}],
publicPath: '/dist'
})
}, {
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: ['es2015']
}
}
}, {
test: /\.woff2?$|\.ttf$|\.eot$|\.svg$/,
use: [{
loader: "file-loader",
options: {
// name: '[path][name].[ext]',
publicPath: './'
}
}]
}]
},
devServer: {
// contentBase: path.join(__dirname, "dist"),
// contentBase: 'build/', // Relative directory for base of server
// publicPath: '/',
// inline: true,
port: process.env.PORT || 3000,
host: '192.168.158.8',
stats: "errors-only",
},
plugins: debug ? [
new HtmlWebpackPlugin({
title: 'BORM',
// minify: {
// collapseWhitespace: true
// },
filename: './../index.html',
// hash: true,
template: './src/index.html',
}),
extractLESS,
new webpack.ProvidePlugin({
$: "jquery",
jQuery: "jquery" // to big after build !!!
})
] : [
new webpack.optimize.DedupePlugin(),
new webpack.optimize.OccurenceOrderPlugin(),
new webpack.optimize.UglifyJsPlugin({ mangle: false, sourcemap: false }),
]
};