1 | const webpack = require('webpack');
|
2 | const path = require('path');
|
3 | const HtmlWebpackPlugin = require('html-webpack-plugin');
|
4 | const CleanWebpackPlugin = require('clean-webpack-plugin');
|
5 | const OpenBrowserPlugin = require('open-browser-webpack-plugin');
|
6 |
|
7 | process.env.NODE_ENV = 'production';
|
8 |
|
9 | module.exports = {
|
10 | entry: {
|
11 | main: './example/src/index.js',
|
12 | zaro: ['react', 'react-dom', 'zaro']
|
13 |
|
14 | },
|
15 | output: {
|
16 | filename: '[name].[chunkhash].js',
|
17 | path: path.resolve(__dirname, 'build')
|
18 | },
|
19 | plugins: [
|
20 | new CleanWebpackPlugin('build'),
|
21 | new webpack.optimize.CommonsChunkPlugin({
|
22 | name: 'zaro',
|
23 | minChunks: Infinity,
|
24 | filename: 'zaro.js'
|
25 | }),
|
26 |
|
27 | new HtmlWebpackPlugin({
|
28 |
|
29 | title: 'test',
|
30 | template: 'src/template/basic.html'
|
31 | }),
|
32 |
|
33 | new OpenBrowserPlugin({
|
34 | url: 'http://localhost:8000'
|
35 | }),
|
36 |
|
37 | ],
|
38 | module: {
|
39 | rules: [{
|
40 | test: /\.(js|jsx)$/,
|
41 | exclude: /node_modules/,
|
42 | use: [
|
43 | 'babel-loader'
|
44 | ]
|
45 | }, {
|
46 | test: /\.(css|scss)$/,
|
47 | exclude: /node_modules/,
|
48 | use: [
|
49 | 'style-loader',
|
50 | 'css-loader',
|
51 | 'sass-loader'
|
52 | ]
|
53 | }, {
|
54 | test: /(\.jp(e)g|\.png|\.gif|\.svg)$/,
|
55 | exclude: /node_modules/,
|
56 | use: {
|
57 | loader: 'file-loader',
|
58 | query: {
|
59 | name: '[name].[ext]'
|
60 | },
|
61 | }
|
62 | }]
|
63 | },
|
64 | resolve: {
|
65 | alias: {
|
66 | zaro: path.resolve(__dirname, '../dist/zaro')
|
67 | }
|
68 | }
|
69 | };
|