-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.dev.js
98 lines (94 loc) · 2.47 KB
/
webpack.config.dev.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
var webpack = require('webpack');
var path = require('path');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
// var AssetsWebpackPlugin = require('assets-webpack-plugin');
var HtmlWebpackPlugin = require('html-webpack-plugin');
var nodeModulesDir = path.join(__dirname, 'node_modules');
var webackConfig = {
entry: {
example: ['./src/modules/example/index.js'],
},
output: {
path: './assets',
filename: '[name].js',
publicPath: '/',
// chunkFilename: "[id].js"
},
// externals: {
// require('jquery') is external and available
// on the global var jQuery
// 'jquery': 'jQuery'
// },
resolve: {
alias: {
},
modulesDirectories: [
path.join(__dirname, 'node_modules'),
path.join(__dirname, 'src'),
],
// root: [
// path.resolve('./src')
// ],
extensions: ['', '.js', '.jsx', '.less'],
},
plugins: [
// new webpack.optimize.CommonsChunkPlugin({ name: 'vendor' }),
new webpack.NoErrorsPlugin(),
new ExtractTextPlugin(
'[name].css', { allChunks: true }
),
],
module: {
noParse: ['./src/noparse/*'],
loaders: [{
test: /\.js$/,
loaders: ['babel'],
exclude: /(node_modules)/,
// }, {
// test: /\.less$/,
// css?-autoprefixer!postcss!less
// loader: ExtractTextPlugin.extract('style', 'css?-autoprefixer!postcss!less')
// }, {
// test: /\.css$/,
// loader: 'style!css'
}, {
test: /\.less$/,
loader: ExtractTextPlugin.extract('style', 'css?-autoprefixer!less'),
}, {
test: /\.css$/,
loader: ExtractTextPlugin.extract('style-loader', 'css-loader'),
}, {
test: /\.jpg|\.png$/,
loader: 'file-loader',
}, {
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&minetype=application/font-woff',
}, {
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader',
}],
},
devServer: {
host: '0.0.0.0',
port: 3000,
disableHostCheck: true,
historyApiFallback: {
index: '/index.html',
},
headers: {
'Access-Control-Allow-Origin': '*',
},
},
};
// if (env === 'production') {
webackConfig.plugins.push(new webpack.DefinePlugin({
ENV: 'devepoment',
}));
webackConfig.plugins.push(new HtmlWebpackPlugin({
template: path.join(__dirname, 'src/views/index.html'),
chunks: ['example'],
minify: {
collapseWhitespace: true,
},
}));
module.exports = webackConfig;