1 | var ExtractTextPlugin = require('extract-text-webpack-plugin');
|
2 | var path = require('path');
|
3 | var webpack = require('webpack');
|
4 |
|
5 | var config = {
|
6 | entry: {
|
7 | 'codeages-design': ['./src/less/codeages-design.less', './src/codeages-design.js'],
|
8 | 'cd-main-color': ['./src/less/main-color.less']
|
9 | },
|
10 | output: {
|
11 | libraryTarget: 'umd',
|
12 | library: 'cd',
|
13 | path: path.resolve(__dirname, 'dist'),
|
14 | filename: '[name].js',
|
15 | publicPath: '/',
|
16 | },
|
17 | externals: {
|
18 | jquery: '$',
|
19 | },
|
20 | resolve: {
|
21 | extensions: ['*', '.js'],
|
22 | },
|
23 | module: {
|
24 | rules: [
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 | {
|
35 | test: /\.js/,
|
36 | loader: 'babel-loader',
|
37 | include: [path.resolve(__dirname, 'src')]
|
38 | },
|
39 | {
|
40 | test: /\.css$/,
|
41 | use: ExtractTextPlugin.extract({
|
42 | fallback: 'style-loader',
|
43 | use: [{
|
44 | loader: 'css-loader',
|
45 | options: {
|
46 | minimize: true,
|
47 | }
|
48 | }]
|
49 | })
|
50 | },
|
51 | {
|
52 | test: /\.less$/,
|
53 | use: ExtractTextPlugin.extract({
|
54 | fallback: 'style-loader',
|
55 | use: [{
|
56 | loader: 'css-loader',
|
57 | options: {
|
58 | minimize: true,
|
59 | }
|
60 | }, {
|
61 | loader: 'less-loader'
|
62 | }]
|
63 | })
|
64 | },
|
65 | {
|
66 | test: /\.(png|jpe?g|gif)(\?.*)?$/,
|
67 | loader: 'url-loader',
|
68 | options: {
|
69 | limit: 1,
|
70 | name: 'img/[name].[ext]'
|
71 | }
|
72 | },
|
73 | {
|
74 | test: /\.(woff2?|eot|ttf|otf|svg)(\?.*)?$/,
|
75 | loader: 'url-loader',
|
76 | options: {
|
77 | limit: 1,
|
78 | name: 'fonts/[name].[ext]'
|
79 | }
|
80 | }
|
81 | ]
|
82 | },
|
83 | plugins: [
|
84 | new ExtractTextPlugin({
|
85 | filename: '[name].css',
|
86 | allChunks: true
|
87 | }),
|
88 | new webpack.DefinePlugin({
|
89 | 'process.env': {
|
90 | 'NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
|
91 | }
|
92 | }),
|
93 | new webpack.optimize.UglifyJsPlugin({
|
94 | compress: {
|
95 | warnings: false,
|
96 | drop_console: true,
|
97 | },
|
98 | })
|
99 | ]
|
100 | }
|
101 |
|
102 | module.exports = config; |
\ | No newline at end of file |