This repository has been archived by the owner on Jan 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.base.js
126 lines (120 loc) · 2.8 KB
/
webpack.config.base.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
var path = require('path');
var webpack = require('webpack');
var autoprefixer = require("autoprefixer");
var easyImport = require("postcss-easy-import");
var mediaMinMax = require('postcss-media-minmax');
var customMedia = require("postcss-custom-media");
var mixins = require('postcss-mixins');
var calc = require('postcss-calc');
var cssVariables = require('postcss-css-variables');
var colorFunction = require('postcss-color-function');
var conditionals = require('postcss-conditionals');
var each = require('postcss-each');
var nested = require('postcss-nested');
var nestedAncestors = require('postcss-nested-ancestors');
var colorRgbaFallback = require("postcss-color-rgba-fallback");
var opacityFallback = require('postcss-opacity');
var cssnext = require('postcss-cssnext');
var mqpacker = require('css-mqpacker');
// Webpack loaders list
var loaders = [
{
test: /\.js$/,
loaders: ['babel'],
include: [path.join(__dirname, './src'), '/node_modules/']
},
{
test: /\.sss$/,
loader: 'style!css!postcss?parser=sugarss',
include: path.join(__dirname, './src')
},
{
test: /\.css$/,
loader: 'style!css!postcss',
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(ttf|woff(2)?|eot|svg|png|jpg|jpeg)$/,
loader: 'url?limit=10000'
}
];
// Webpack plugins
var plugins = [
new webpack.DefinePlugin({
'__BROWSER__': true
}),
// new styleLint({
// configFile: '.stylelintrc',
// files: '**/*.s?(a|c)ss',
// syntax: 'sugarss'
// })
// new CopyWebpackPlugin([
// { from: 'src/images', to: 'images/' }
// ]),
// webpackIsomorphicToolsPlugin
new webpack.NoErrorsPlugin(),
];
// PostCSS init
var postcss = function (webpack) {
return [
mqpacker(),
easyImport({ extensions: ['.sss'] }),
mixins,
nestedAncestors,
nested,
cssnext(),
// mediaMinMax(),
// customMedia(),
// autoprefixer({ browsers: ['> 2% in IR', 'ie >= 8'] }),
// mixins,
// conditionals,
// cssVariables,
calc,
each,
// nestedAncestors,
// nested,
colorFunction,
colorRgbaFallback(),
opacityFallback,
];
};
// Resolve
var resolve = {
extensions: ['', '.sss', '.css', '.js']
};
// Main config object
var config = {
entry: './src/index.js',
output: {
path: path.join(__dirname, 'dist'),
filename: "bundle.js",
publicPath: '/dist/'
},
module: {
loaders: loaders
},
plugins: plugins,
postcss: postcss,
resolve: resolve,
// target: 'node',
// node: {
// fs: {},
// net: {},
// tls: {},
// tmp: {},
// // fs: "empty",
// // net: "empty",
// // tls: "empty",
// // tmp: "empty",
// console: false,
// global: false,
// process: false,
// Buffer: false,
// __filename: false,
// __dirname: false,
// }
};
module.exports = config;