-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwebpack.config.js
More file actions
61 lines (58 loc) · 1.62 KB
/
webpack.config.js
File metadata and controls
61 lines (58 loc) · 1.62 KB
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
const Path = require('path');
const webpack = require('webpack');
// Import the core config
const webpackConfig = require('@silverstripe/webpack-config');
const {
resolveJS,
externalJS,
moduleJS,
pluginJS,
moduleCSS,
pluginCSS,
} = webpackConfig;
const ENV = process.env.NODE_ENV;
const PATHS = {
// the root path, where your webpack.config.js is located.
ROOT: Path.resolve(),
// your node_modules folder name, or full path
MODULES: Path.resolve('node_modules'),
// relative path from your css files to your other files, such as images and fonts
FILES_PATH: '../',
// thirdparty folder containing copies of packages which wouldn't be available on NPM
THIRDPARTY: 'thirdparty',
// the root path to your javascript source files
SRC: Path.resolve('client/src'),
DIST: Path.resolve('client/dist')
};
const config = [
{
name: 'js',
entry: {
main: `${PATHS.SRC}/boot/index.js`
},
output: {
path: PATHS.DIST,
filename: 'js/[name].js'
},
devtool: (ENV !== 'production') ? 'source-map' : '',
resolve: Object.assign({}, resolveJS(ENV, PATHS), {extensions: ['.json', '.js', '.jsx']}),
externals: externalJS(ENV, PATHS),
module: moduleJS(ENV, PATHS),
plugins: pluginJS(ENV, PATHS)
},
{
name: 'css',
entry: {
main: `${PATHS.SRC}/styles/main.css`,
cropperjs: `${PATHS.MODULES}/cropperjs/dist/cropper.css`
},
output: {
path: PATHS.DIST,
filename: 'styles/[name].css',
},
devtool: (ENV !== 'production') ? 'source-map' : '',
module: moduleCSS(ENV, PATHS),
plugins: pluginCSS(ENV, PATHS),
},
];
module.exports = config;