-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrazzle.config.js
109 lines (100 loc) · 3.31 KB
/
razzle.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
104
105
106
107
108
109
const
path = require('path'),
MonacoWebpackPlugin = require('monaco-editor-webpack-plugin'),
UCNModulePlugin = require('./ucn-webpack-plugin')
module.exports = {
options: {
verbose: false,
buildType: 'iso',
cssPrefix: 'static/css',
jsPrefix: 'static/js',
mediaPrefix: 'static/media'
},
modifyWebpackOptions( opts ){
const options = opts.options.webpackOptions
// Add .marko to exlude
options.fileLoaderExclude = [ /\.marko$/, /\.ya?ml$/, ...options.fileLoaderExclude ]
return options
},
modifyWebpackConfig({ webpackConfig }){
// Client.js moved to `/src/frontend` folder
if( webpackConfig.entry.client ){
const clientPath = path.join( __dirname, '/src/frontend/client' )
webpackConfig.mode == 'production' ?
webpackConfig.entry.client = clientPath
: webpackConfig.entry.client[1] = clientPath
}
webpackConfig.resolve.extensions = [ ...webpackConfig.resolve.extensions, '.css', '.scss', '.marko', '.yml', '.yaml' ]
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
'test': path.resolve(__dirname, './test'),
'public': path.resolve(__dirname, './public'),
'frontend': path.resolve(__dirname, './src/frontend'),
'pages': path.resolve(__dirname, './src/frontend/views/pages'),
'assets': path.resolve(__dirname, './src/frontend/views/assets'),
// Important modules
'vscode': require.resolve('@codingame/monaco-languageclient/lib/vscode-compatibility'),
// 'fs-inter': require.resolve('./src/backend/lib/Inter/fs'),
// 'path-inter': require.resolve('./src/backend/lib/Inter/path'),
// Important project
'handlers': path.resolve(__dirname, './custom/handlers'),
'plugins': path.resolve(__dirname, './custom/plugins'),
'store': path.resolve(__dirname, './store'),
'sync': path.resolve(__dirname, './sync')
}
webpackConfig.resolve.fallback = {
...webpackConfig.resolve.fallback,
// Assert: require.resolve('assert'),
path: require.resolve('path-browserify'),
/*
* Stream: require.resolve('stream-browserify'),
* crypto: require.resolve('crypto-browserify')
*/
}
webpackConfig.module.rules.push({
test: /\.marko$/,
loader: require.resolve('@marko/webpack/loader')
})
webpackConfig.module.rules.push({
test: /\.s[ac]ss$/i,
use: [
'style-loader', // Creates `style` nodes from JS strings
'css-loader', // Translates CSS into CommonJS
'sass-loader' // Compiles Sass to CSS
]
})
webpackConfig.module.rules.push({
test: /\.ya?ml$/,
use: 'yaml-loader'
})
// webpackConfig.module.rules.push({
// test: /\.ucn$/,
// use: require.resolve('./ucn-loader.js')
// })
webpackConfig.module.rules.push({
test: /\.worker\.(c|m)?js$/i,
loader: 'worker-loader',
options: { inline: true }
})
const monacoConfig = {
languages: [
'css',
'html',
'javascript',
'json',
'less',
'scss',
'typescript',
'jsx',
'tsx',
'marko'
]
}
webpackConfig.plugins = [
...webpackConfig.plugins,
new MonacoWebpackPlugin( monacoConfig ),
new UCNModulePlugin()
]
return webpackConfig
}
}