@lightscale/webpack-config 1.0.3 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +96 -19
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -7,8 +7,7 @@ import EsLintPlugin from 'eslint-webpack-plugin';
|
|
|
7
7
|
import WebpackbarPlugin from 'webpackbar';
|
|
8
8
|
import CleanTerminalPlugin from 'clean-terminal-webpack-plugin';
|
|
9
9
|
import {CleanWebpackPlugin} from 'clean-webpack-plugin';
|
|
10
|
-
import
|
|
11
|
-
|
|
10
|
+
import Autoprefixer from 'autoprefixer';
|
|
12
11
|
|
|
13
12
|
export class Paths {
|
|
14
13
|
#jsSourcePath;
|
|
@@ -30,6 +29,89 @@ export class Paths {
|
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
31
|
|
|
32
|
+
const babelConfig = {
|
|
33
|
+
presets: [
|
|
34
|
+
"@babel/preset-env"
|
|
35
|
+
],
|
|
36
|
+
plugins: [
|
|
37
|
+
["polyfill-corejs3", { method: "usage-global"}]
|
|
38
|
+
],
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const postCssConfig = {
|
|
42
|
+
plugins: [
|
|
43
|
+
Autoprefixer
|
|
44
|
+
]
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const esLintConfig = {
|
|
48
|
+
'root': true,
|
|
49
|
+
'extends': [
|
|
50
|
+
'eslint:recommended'
|
|
51
|
+
],
|
|
52
|
+
'globals': {
|
|
53
|
+
'wp': true,
|
|
54
|
+
},
|
|
55
|
+
'env': {
|
|
56
|
+
'node': true,
|
|
57
|
+
'es6': true,
|
|
58
|
+
'amd': true,
|
|
59
|
+
'browser': true,
|
|
60
|
+
'jquery': true,
|
|
61
|
+
},
|
|
62
|
+
'parser': '@babel/eslint-parser',
|
|
63
|
+
'parserOptions': {
|
|
64
|
+
'ecmaFeatures': {
|
|
65
|
+
'globalReturn': true,
|
|
66
|
+
'generators': false,
|
|
67
|
+
'objectLiteralDuplicateProperties': false,
|
|
68
|
+
'experimentalObjectRestSpread': true,
|
|
69
|
+
},
|
|
70
|
+
'ecmaVersion': 2017,
|
|
71
|
+
'sourceType': 'module',
|
|
72
|
+
'requireConfigFile': false,
|
|
73
|
+
},
|
|
74
|
+
'plugins': [
|
|
75
|
+
|
|
76
|
+
],
|
|
77
|
+
'settings': {
|
|
78
|
+
'import/core-modules': [],
|
|
79
|
+
'import/ignore': [
|
|
80
|
+
'node_modules',
|
|
81
|
+
'\\.(coffee|scss|css|less|hbs|svg|json)$',
|
|
82
|
+
]
|
|
83
|
+
},
|
|
84
|
+
'rules': {
|
|
85
|
+
'no-console': 0,
|
|
86
|
+
'quotes': ['error', 'single'],
|
|
87
|
+
'semi': ['warn', 'always'],
|
|
88
|
+
'comma-dangle': 0,
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const styleLintConfig = {
|
|
93
|
+
'extends': 'stylelint-config-standard',
|
|
94
|
+
'plugins': ['stylelint-scss'],
|
|
95
|
+
'customSyntax': 'postcss-scss',
|
|
96
|
+
'rules': {
|
|
97
|
+
'no-empty-source': null,
|
|
98
|
+
//'selector-id-pattern': null,
|
|
99
|
+
'selector-class-pattern': null, // TODO: remove and fix
|
|
100
|
+
'at-rule-no-unknown': null,
|
|
101
|
+
'function-no-unknown': null,
|
|
102
|
+
'no-invalid-position-at-import-rule': [
|
|
103
|
+
true,
|
|
104
|
+
{
|
|
105
|
+
ignoreAtRules: ["/^use$/"]
|
|
106
|
+
}
|
|
107
|
+
],
|
|
108
|
+
'scss/at-rule-no-unknown': true,
|
|
109
|
+
'import-notation': null,
|
|
110
|
+
'annotation-no-unknown': null,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
|
|
33
115
|
export const makeConfig = (env, argv, options) => {
|
|
34
116
|
const isProd = argv.mode === 'production',
|
|
35
117
|
isDev = argv.mode === 'development',
|
|
@@ -55,7 +137,6 @@ export const makeConfig = (env, argv, options) => {
|
|
|
55
137
|
customize(entry) {
|
|
56
138
|
|
|
57
139
|
if (
|
|
58
|
-
entry.key.startsWith('svg/') ||
|
|
59
140
|
entry.key.endsWith('.map')
|
|
60
141
|
) return false;
|
|
61
142
|
|
|
@@ -78,8 +159,10 @@ export const makeConfig = (env, argv, options) => {
|
|
|
78
159
|
}),
|
|
79
160
|
new StylelintPlugin({
|
|
80
161
|
failOnError: !isWatch,
|
|
162
|
+
config: styleLintConfig,
|
|
81
163
|
}),
|
|
82
164
|
new EsLintPlugin({
|
|
165
|
+
baseConfig: esLintConfig,
|
|
83
166
|
overrideConfig: {
|
|
84
167
|
rules: {
|
|
85
168
|
"no-console": isProd ? 2 : 1,
|
|
@@ -93,11 +176,6 @@ export const makeConfig = (env, argv, options) => {
|
|
|
93
176
|
new NotifierPlugin(),
|
|
94
177
|
new WebpackbarPlugin(),
|
|
95
178
|
new CleanTerminalPlugin(),
|
|
96
|
-
new SvgChunkWebpackPlugin({
|
|
97
|
-
filename: '[name].[contenthash].svg',
|
|
98
|
-
svgstoreConfig: {inline: false},
|
|
99
|
-
}),
|
|
100
|
-
|
|
101
179
|
...plugins,
|
|
102
180
|
],
|
|
103
181
|
|
|
@@ -109,9 +187,10 @@ export const makeConfig = (env, argv, options) => {
|
|
|
109
187
|
{
|
|
110
188
|
test: /\.js$/i,
|
|
111
189
|
include: paths.sourcePath,
|
|
112
|
-
use:
|
|
113
|
-
'babel-loader'
|
|
114
|
-
|
|
190
|
+
use: {
|
|
191
|
+
loader: 'babel-loader',
|
|
192
|
+
options: babelConfig,
|
|
193
|
+
}
|
|
115
194
|
},
|
|
116
195
|
{
|
|
117
196
|
test: /\.s[ac]ss$/i,
|
|
@@ -119,17 +198,15 @@ export const makeConfig = (env, argv, options) => {
|
|
|
119
198
|
use: [
|
|
120
199
|
MiniCssExtractPlugin.loader,
|
|
121
200
|
'css-loader',
|
|
122
|
-
|
|
201
|
+
{
|
|
202
|
+
loader: 'postcss-loader',
|
|
203
|
+
options: {
|
|
204
|
+
postcssOptions: postCssConfig
|
|
205
|
+
}
|
|
206
|
+
},
|
|
123
207
|
'sass-loader',
|
|
124
208
|
],
|
|
125
209
|
},
|
|
126
|
-
{
|
|
127
|
-
test: /.svg$/i,
|
|
128
|
-
include: paths.sourcePath,
|
|
129
|
-
use: [
|
|
130
|
-
{loader: SvgChunkWebpackPlugin.loader}
|
|
131
|
-
]
|
|
132
|
-
}
|
|
133
210
|
],
|
|
134
211
|
},
|
|
135
212
|
|