mirror of
https://github.com/ElemeFE/element.git
synced 2025-12-19 12:04:02 +08:00
Chore: convert build system to webpack (#11216)
* Chore: convert build system to webpack * Update webpack.demo.js * Chore: remove cooking and upgrade dependencies to adapt webpack@3
This commit is contained in:
91
build/webpack.component.js
Normal file
91
build/webpack.component.js
Normal file
@@ -0,0 +1,91 @@
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const ProgressBarPlugin = require('progress-bar-webpack-plugin');
|
||||
|
||||
var Components = require('../components.json');
|
||||
const config = require('./config');
|
||||
|
||||
const webpackConfig = {
|
||||
entry: Components,
|
||||
output: {
|
||||
path: path.resolve(process.cwd(), './lib'),
|
||||
publicPath: '/dist/',
|
||||
filename: '[name].js',
|
||||
chunkFilename: '[id].js',
|
||||
libraryTarget: 'commonjs2'
|
||||
},
|
||||
resolve: {
|
||||
extensions: ['.js', '.vue', '.json'],
|
||||
alias: config.alias,
|
||||
modules: ['node_modules']
|
||||
},
|
||||
externals: config.externals,
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.(jsx?|babel|es6)$/,
|
||||
include: process.cwd(),
|
||||
exclude: config.jsexclude,
|
||||
loader: 'babel-loader'
|
||||
},
|
||||
{
|
||||
test: /\.vue$/,
|
||||
loader: 'vue-loader',
|
||||
options: {
|
||||
preserveWhitespace: false
|
||||
}
|
||||
},
|
||||
{
|
||||
test: /\.json$/,
|
||||
loader: 'json-loader'
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
loaders: ['style-loader', 'css-loader', 'postcss-loader']
|
||||
},
|
||||
{
|
||||
test: /\.scss$/,
|
||||
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*)?$/,
|
||||
loader: 'url-loader',
|
||||
query: {
|
||||
limit: 10000,
|
||||
name: path.posix.join('static', '[name].[hash:7].[ext]')
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new ProgressBarPlugin(),
|
||||
new webpack.DefinePlugin({
|
||||
'process.env.NODE_ENV': JSON.stringify('production')
|
||||
}),
|
||||
new webpack.LoaderOptionsPlugin({
|
||||
minimize: true
|
||||
})
|
||||
]
|
||||
};
|
||||
|
||||
module.exports = webpackConfig;
|
||||
Reference in New Issue
Block a user