-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathwebpack.config.js
103 lines (95 loc) · 3.01 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
var path = require('path');
var MiniCssExtractPlugin = require('mini-css-extract-plugin');
const TerserPlugin = require('terser-webpack-plugin');
var webpack = require('webpack');
module.exports = (env) => ({
mode: env.NODE_ENV || 'development',
optimization: {
minimizer: [new TerserPlugin({ /* additional options here */ })],
},
context: path.resolve(__dirname),
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.scss', '.png', '.jpg', '.jpeg', '.svg'],
alias: {
'code-mirror': path.join(__dirname, 'node_modules/codemirror/lib'),
react: path.join(__dirname, 'node_modules/react'),
'react-dom': path.join(__dirname, 'node_modules/react-dom'),
'react-redux': path.join(__dirname, 'node_modules/react-redux'),
},
symlinks: false
},
entry: ['./lib/client/jsx/timur.jsx', './lib/client/scss/application.scss'],
output: {
filename: 'public/js/timur.bundle.js',
path: __dirname,
publicPath: '/js/'
},
module: {
rules: [
{
loader: 'babel-loader',
// Skip any files outside of your project's `src` directory
include: [
path.resolve(__dirname, 'lib/client/jsx'),
path.resolve(__dirname, 'node_modules/etna-js/'),
'/etna/packages/etna-js'
],
// Only run `.js` and `.jsx` files through Babel
test: /\.(js|ts)x?$/
},
{
loader: ['style-loader', 'css-loader'],
include: [
path.resolve(__dirname, 'node_modules/etna-js/'),
path.resolve(__dirname, 'node_modules/animate.css/'),
path.resolve(__dirname, 'node_modules/react-notifications-component'),
path.resolve(__dirname, 'node_modules/codemirror/'),
'/etna/packages/etna-js'
],
test: /\.css$/
},
{
loader: 'file-loader',
include: [
path.resolve(__dirname, 'node_modules/etna-js/'),
'/etna/packages/etna-js',
path.resolve(__dirname, 'lib/client/img/')
],
test: /\.(jpe?g|png|svg)$/i,
options: {
name: '[name].[ext]',
outputPath: 'public/images/',
publicPath: '/images'
}
},
{
// sass / scss loader for webpack
test: /\.(sass|scss)$/,
include: [
path.resolve(
__dirname,
'node_modules/react-loader-spinner/dist/loader/css'
),
path.resolve(__dirname, 'lib/client/scss')
],
// loader: ExtractTextPlugin.extract(['css-loader', 'sass-loader'])
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
}
]
},
plugins: [
// new ExtractTextPlugin({
// // define where to save the file
// filename: 'public/css/timur.bundle.css',
// allChunks: true
// }),
new MiniCssExtractPlugin({
filename: 'public/css/timur.bundle.css',
}),
// new webpack.DefinePlugin({
// 'process.env': {
// NODE_ENV: JSON.stringify(env ? env.NODE_ENV : 'development')
// }
// })
]
});