UNPKG

2.35 kBJavaScriptView Raw
1const path = require('path');
2const webpack = require('webpack');
3const NpmInstallPlugin = require('npm-install-webpack-plugin');
4const ExtractTextPlugin = require('extract-text-webpack-plugin');
5
6
7const config = {
8 entry: {
9 index: "./src/index.js"
10 },
11 output: {
12 path: path.resolve(__dirname, "site"),
13 filename: "[name].js"
14 },
15 resolve: {
16 extensions: [".js", ".json", ".jsx", ".css"],
17 },
18 module: {
19
20 },
21 module: {
22 rules: [
23 {
24 test: /\.jsx?$/,
25 include: [
26 path.resolve(__dirname, "src")
27 ],
28 use: ['babel-loader']
29 },
30 {
31 test: /\.css$/,
32 use: [ 'style-loader', 'css-loader' ]
33 },
34 {
35 test: /\.md$/,
36 use: ['babel-loader', path.resolve(__dirname, 'src/lib/md-loader.js') ]
37 },
38 {
39 test: /\.less$/,
40 use: [{
41 loader: "style-loader" // creates style nodes from JS strings
42 }, {
43 loader: "css-loader" // translates CSS into CommonJS
44 }, {
45 loader: "less-loader" // compiles Less to CSS
46 }]
47 }
48 ],
49 },
50
51 devtool: "source-map",
52
53 devServer: {
54 // proxy: { // proxy URLs to backend development server
55 // '/api': 'http://localhost:3000'
56 // },
57 host: "0.0.0.0",
58 port: 9000,
59 contentBase: path.join(__dirname, 'site'), // boolean | string | array, static file location
60 compress: true, // enable gzip compression
61 historyApiFallback: true, // true for index.html upon 404, object for multiple paths
62 hot: true, // hot module replacement. Depends on HotModuleReplacementPlugin
63 https: false, // true for self-signed, object for cert authority
64 noInfo: true, // only errors & warns on hot reload
65 publicPath: '/'
66 // ...
67 },
68
69 plugins: [
70 new webpack.HotModuleReplacementPlugin(),
71 new webpack.DefinePlugin({
72 'process.env.NODE_ENV': '"production"',
73 }),
74 new ExtractTextPlugin({filename: '[name].css', disable: false, allChunks: true}),
75 // new NpmInstallPlugin()
76 ]
77
78}
79
80module.exports = config;
\No newline at end of file