Skip to content

Commit

Permalink
Chore: upgrade to webpack@4 (ElemeFE#14173)
Browse files Browse the repository at this point in the history
* Chore: upgrade webpack@4

* Chore: upgrade to webpack@4

* Chore: add babel-preset-stage-2

* Chore: fix test case

* Chore: upgrade webpack@4

* Docs: update docs

* Docs: update docs

* Chore: fix coveralls

* Chore: update yarn.lock
  • Loading branch information
island205 authored and ziyoung committed Jan 23, 2019
1 parent 439f58f commit aa9851e
Show file tree
Hide file tree
Showing 80 changed files with 6,210 additions and 3,581 deletions.
17 changes: 16 additions & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
{
"presets": [["es2015", { "loose": true }]],
"presets": [
[
"env",
{
"loose": true,
"modules": false,
"targets": {
"browsers": ["> 1%", "last 2 versions", "not ie <= 8"]
}
}
],
"stage-2"
],
"plugins": ["transform-vue-jsx"],
"env": {
"utils": {
Expand All @@ -11,6 +23,9 @@
}
}]
]
},
"test": {
"plugins": ["istanbul"]
}
}
}
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
"no-restricted-globals": ["error", "event", "fdescribe"]
},
"parserOptions": {
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true,
"jsx": true
}
}
Expand Down
4 changes: 1 addition & 3 deletions build/bin/build-entry.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ if (typeof window !== 'undefined' && window.Vue) {
install(window.Vue);
}
module.exports = {
export default {
version: '{{version}}',
locale: locale.use,
i18n: locale.i18n,
Expand All @@ -58,8 +58,6 @@ module.exports = {
Loading,
{{list}}
};
module.exports.default = module.exports;
`;

delete Components.font;
Expand Down
49 changes: 16 additions & 33 deletions build/webpack.common.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const path = require('path');
const webpack = require('webpack');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

const config = require('./config');

module.exports = {
mode: 'production',
entry: {
app: ['./src/index.js']
},
Expand All @@ -21,6 +22,15 @@ module.exports = {
modules: ['node_modules']
},
externals: config.externals,
performance: {
hints: false
},
stats: {
children: false
},
optimization: {
minimize: false
},
module: {
rules: [
{
Expand All @@ -33,13 +43,11 @@ module.exports = {
test: /\.vue$/,
loader: 'vue-loader',
options: {
preserveWhitespace: false
compilerOptions: {
preserveWhitespace: false
}
}
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader']
Expand All @@ -49,27 +57,7 @@ module.exports = {
loaders: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.html$/,
loader: 'html-loader?minimize=false'
},
{
test: /\.otf|ttf|woff2?|eot(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: path.posix.join('static', '[name].[hash:7].[ext]')
}
},
{
test: /\.svg(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: path.posix.join('static', '[name].[hash:7].[ext]')
}
},
{
test: /\.(gif|png|jpe?g)(\?\S*)?$/,
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
Expand All @@ -80,11 +68,6 @@ module.exports = {
},
plugins: [
new ProgressBarPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
new VueLoaderPlugin()
]
};
47 changes: 14 additions & 33 deletions build/webpack.component.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
const path = require('path');
const webpack = require('webpack');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

const Components = require('../components.json');
const config = require('./config');

const webpackConfig = {
mode: 'production',
entry: Components,
output: {
path: path.resolve(process.cwd(), './lib'),
Expand All @@ -20,6 +21,13 @@ const webpackConfig = {
modules: ['node_modules']
},
externals: config.externals,
performance: {
hints: false
},
stats: 'none',
optimization: {
minimize: false
},
module: {
rules: [
{
Expand All @@ -32,13 +40,11 @@ const webpackConfig = {
test: /\.vue$/,
loader: 'vue-loader',
options: {
preserveWhitespace: false
compilerOptions: {
preserveWhitespace: false
}
}
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader']
Expand All @@ -48,27 +54,7 @@ const webpackConfig = {
loaders: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.html$/,
loader: 'html-loader?minimize=false'
},
{
test: /\.otf|ttf|woff2?|eot(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: path.posix.join('static', '[name].[hash:7].[ext]')
}
},
{
test: /\.svg(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: path.posix.join('static', '[name].[hash:7].[ext]')
}
},
{
test: /\.(gif|png|jpe?g)(\?\S*)?$/,
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
Expand All @@ -79,12 +65,7 @@ const webpackConfig = {
},
plugins: [
new ProgressBarPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
new VueLoaderPlugin()
]
};

Expand Down
55 changes: 13 additions & 42 deletions build/webpack.conf.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
const path = require('path');
const webpack = require('webpack');
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const VueLoaderPlugin = require('vue-loader/lib/plugin');

const config = require('./config');

module.exports = {
mode: 'production',
entry: {
app: ['./src/index.js']
},
Expand All @@ -24,6 +25,12 @@ module.exports = {
externals: {
vue: config.vue
},
performance: {
hints: false
},
stats: {
children: false
},
module: {
rules: [
{
Expand All @@ -36,13 +43,11 @@ module.exports = {
test: /\.vue$/,
loader: 'vue-loader',
options: {
preserveWhitespace: false
compilerOptions: {
preserveWhitespace: false
}
}
},
{
test: /\.json$/,
loader: 'json-loader'
},
{
test: /\.css$/,
loaders: ['style-loader', 'css-loader', 'postcss-loader']
Expand All @@ -52,27 +57,7 @@ module.exports = {
loaders: ['style-loader', 'css-loader', 'sass-loader']
},
{
test: /\.html$/,
loader: 'html-loader?minimize=false'
},
{
test: /\.otf|ttf|woff2?|eot(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: path.posix.join('static', '[name].[hash:7].[ext]')
}
},
{
test: /\.svg(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
name: path.posix.join('static', '[name].[hash:7].[ext]')
}
},
{
test: /\.(gif|png|jpe?g)(\?\S*)?$/,
test: /\.(svg|otf|ttf|woff2?|eot|gif|png|jpe?g)(\?\S*)?$/,
loader: 'url-loader',
query: {
limit: 10000,
Expand All @@ -83,20 +68,6 @@ module.exports = {
},
plugins: [
new ProgressBarPlugin(),
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production')
}),
new webpack.optimize.UglifyJsPlugin({
compress: {
warnings: false
},
output: {
comments: false
},
sourceMap: false
}),
new webpack.LoaderOptionsPlugin({
minimize: true
})
new VueLoaderPlugin()
]
};
Loading

0 comments on commit aa9851e

Please sign in to comment.