forked from insideout10/wordlift-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config~1.js
84 lines (79 loc) · 2.22 KB
/
webpack.config~1.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
const webpack = require( 'webpack' );
const path = require( 'path' );
const tests = require( './.build/webpack/tests' );
// @todo: consider splitting vendor, see:
// * https://robertknight.github.io/posts/webpack-dll-plugins/
// * https://webpack.js.org/concepts/entry-points/
// @todo: add the other files:
// * wordlift, for the WordPress front-end,
// * wordlift-admin, for the WordPress admin,
// * wordlift-editor, for the WordPress TinyMCE editor.
// see https://webpack.js.org/concepts/output/#output-filename.
// @todo: migration, we're migrating all the JavaScript files to WebPack and
// organizing them in three main files (front-end, admin, editor). For some time
// the old files and the new files will cohexist.
const config = [
tests, {
entry: {
'wordlift-admin': './src/admin/js/wordlift-admin.js',
'wordlift-admin-edit-page': './src/scripts/admin-edit-page/index.js',
'wordlift-admin-settings-page': './src/scripts/admin-settings-page/index.js',
'wordlift-admin-tinymce': './src/scripts/admin-tinymce/index.js',
'wordlift-author-element': './src/scripts/author-element/index.js'
},
output: {
path: path.resolve( __dirname, 'src/admin/js' ),
filename: '[name].bundle.js'
},
module: {
rules: [
// `eslint`.
{
test: /\.js$/,
exclude: /node_modules/,
// `eslint` runs before any other loader.
enforce: 'pre',
use: 'eslint-loader',
},
// `babel`.
{
test: /\.(js|jsx)$/,
use: 'babel-loader',
exclude: /node_modules\/(?!(react-select)\/).*/,
},
// Stylesheets.
//
// Do not enable `css-loader?modules` or global styles define in
// `src/scripts/admin-settings-page/index.scss` will fail.
{
test: /\.scss$/,
use: [
'style-loader',
'css-loader',
'sass-loader'
]
},
{
test: /\.png$/,
use: { loader: 'url-loader', options: { limit: 2000 } },
},
{
test: /\.jpg$/,
use: 'file-loader'
},
{
test: /\.css$/,
loader: [ 'style-loader', 'css-loader' ]
}
]
},
plugins: [
new webpack.DefinePlugin(
{
'process.env': { NODE_ENV: JSON.stringify( 'production' ) }
} )
],
devtool: 'cheap-module-source-map'
}
];
module.exports = config;