forked from Shopify/theme-tools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.config.js
97 lines (94 loc) · 2.71 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
//@ts-check
/** @typedef {import('webpack').Configuration} WebpackConfig **/
'use strict';
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
const { default: TsconfigPathsPlugin } = require('tsconfig-paths-webpack-plugin');
const path = require('path');
/** @type WebpackConfig */
const config = {
target: 'node',
entry: {
extension: './src/extension.ts',
server: './src/server.ts',
},
output: {
path: path.resolve(__dirname, 'dist'),
filename: '[name].js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]',
},
context: path.resolve(__dirname),
externals: {
vscode: 'commonjs vscode', // the vscode-module is created on-the-fly and must be excluded
prettier: 'commonjs ./prettier',
},
resolve: {
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js'],
plugins: [new TsconfigPathsPlugin({})],
},
optimization: {
minimize: false,
},
module: {
parser: {
javascript: {
commonjsMagicComments: true,
},
},
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: {
loader: 'ts-loader',
options: {
projectReferences: true,
},
},
},
],
},
devtool: 'source-map',
plugins: [
new webpack.DefinePlugin({
// A flag that lets us do fun webpack-only shenanigans...
'process.env.WEBPACK_MODE': true,
}),
new CopyPlugin({
patterns: [
{
// The config/* yaml files need to be accessible from the VS Code
// extension. So we copy them into the dist/configs folder so that
// the __dirname eval can correctly load them. It's a bit hacky,
// buit it works :)
//
// This is also why we have __dirname as 'eval-only'.
from: path.resolve(__dirname, '../theme-check-node/configs'),
to: 'configs',
},
{
// Same deal but for the fallback docset and schema files.
from: path.resolve(__dirname, '../theme-check-docs-updater/data'),
to: 'data',
},
{
from: path.resolve(__dirname, '../../node_modules/prettier'),
to: 'prettier',
globOptions: {
ignore: ['**/esm/**'],
},
},
],
}),
],
node: {
__filename: 'eval-only', // this means that __filename will eval to the output file name
__dirname: 'eval-only', // this means that __dirname will eval to the dist folder
},
infrastructureLogging: {
level: 'log', // enables logging required for problem matchers
},
};
module.exports = [config];