-
Notifications
You must be signed in to change notification settings - Fork 28
/
webpack.config.js
60 lines (57 loc) · 1.33 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const path = require('path');
const WebpackAssetsManifest = require('webpack-assets-manifest');
const webpack = require('webpack');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const { NODE_ENV } = process.env;
const isProd = NODE_ENV === 'production';
module.exports = {
mode: isProd ? 'production' : 'development',
devtool: 'source-map',
entry: {
application: path.resolve(__dirname, 'app/javascript/packs/application.js'),
},
output: {
path: path.resolve(__dirname, 'public/packs'),
publicPath: process.env.USE_WEBPACK_DEV_SERVER === '1' ? '//localhost:3035/packs/' : '/packs/',
filename: '[name]-[chunkhash].js',
},
module: {
rules: [
{
test: /\.css$/,
use: [
MiniCssExtractPlugin.loader,
'css-loader',
],
},
],
},
resolve: {
extensions: ['.js', '.css'],
alias: {
},
},
devServer: {
devMiddleware: {
publicPath: '/packs/',
},
host: 'localhost',
port: 3035,
headers: {
'Access-Control-Allow-Origin': '*',
},
},
plugins: [
new WebpackAssetsManifest({
publicPath: true,
writeToDisk: true,
}),
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
}),
new MiniCssExtractPlugin({
filename: '[name]-[contenthash].css',
}),
],
};